Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / drush / drush / src / Drupal / Commands / pm / ThemeCommands.php
1 <?php
2 namespace Drush\Drupal\Commands\pm;
3
4 use Drupal\Core\Extension\ThemeInstallerInterface;
5 use Drush\Commands\DrushCommands;
6 use Drush\Drush;
7 use Drush\Utils\StringUtils;
8
9 class ThemeCommands extends DrushCommands
10 {
11
12     protected $themeInstaller;
13
14     public function __construct(ThemeInstallerInterface $themeInstaller)
15     {
16         parent::__construct();
17         $this->themeInstaller = $themeInstaller;
18     }
19
20     /**
21      * @return mixed
22      */
23     public function getThemeInstaller()
24     {
25         return $this->themeInstaller;
26     }
27
28     /**
29      * Enable one or more themes.
30      *
31      * @command theme:enable
32      * @param $themes A comma delimited list of themes.
33      * @aliases then,theme-enable
34      */
35     public function enable($themes)
36     {
37         $themes = StringUtils::csvToArray($themes);
38         if (!$this->getThemeInstaller()->install($themes, true)) {
39             throw new \Exception('Unable to install themes.');
40         }
41         $this->logger()->success(dt('Successfully enabled theme: !list', ['!list' => implode(', ', $themes)]));
42     }
43
44     /**
45      * Uninstall theme.
46      *
47      * @command theme:uninstall
48      * @param $themes A comma delimited list of themes.
49      * @aliases thun,theme-uninstall
50      */
51     public function uninstall($themes)
52     {
53         $themes = StringUtils::csvToArray($themes);
54         if (!$this->getThemeInstaller()->uninstall($themes, true)) {
55             throw new \Exception('Unable to uninstall themes.');
56         }
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();
60         $boot->addLogger();
61     }
62 }