2 namespace Drush\Drupal\Commands\pm;
4 use Drupal\Core\Extension\ThemeInstallerInterface;
5 use Drush\Commands\DrushCommands;
7 use Drush\Utils\StringUtils;
9 class ThemeCommands extends DrushCommands
12 protected $themeInstaller;
14 public function __construct(ThemeInstallerInterface $themeInstaller)
16 parent::__construct();
17 $this->themeInstaller = $themeInstaller;
23 public function getThemeInstaller()
25 return $this->themeInstaller;
29 * Enable one or more themes.
31 * @command theme:enable
32 * @param $themes A comma delimited list of themes.
33 * @aliases then,theme-enable
35 public function enable($themes)
37 $themes = StringUtils::csvToArray($themes);
38 if (!$this->getThemeInstaller()->install($themes, true)) {
39 throw new \Exception('Unable to install themes.');
41 $this->logger()->success(dt('Successfully enabled theme: !list', ['!list' => implode(', ', $themes)]));
47 * @command theme:uninstall
48 * @param $themes A comma delimited list of themes.
49 * @aliases thun,theme-uninstall
51 public function uninstall($themes)
53 $themes = StringUtils::csvToArray($themes);
54 if (!$this->getThemeInstaller()->uninstall($themes, true)) {
55 throw new \Exception('Unable to uninstall themes.');
57 $this->logger()->success(dt('Successfully uninstalled theme: !list', ['!list' => implode(', ', $themes)]));
58 // Our logger got blown away during the container rebuild above.
59 $boot = Drush::bootstrapManager()->bootstrap();