Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / src / Drupal / Commands / pm / ThemeCommands.php
diff --git a/vendor/drush/drush/src/Drupal/Commands/pm/ThemeCommands.php b/vendor/drush/drush/src/Drupal/Commands/pm/ThemeCommands.php
new file mode 100644 (file)
index 0000000..b4e6218
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace Drush\Drupal\Commands\pm;
+
+use Drupal\Core\Extension\ThemeInstallerInterface;
+use Drush\Commands\DrushCommands;
+use Drush\Drush;
+
+class ThemeCommands extends DrushCommands
+{
+
+    protected $themeInstaller;
+
+    public function __construct(ThemeInstallerInterface $themeInstaller)
+    {
+        parent::__construct();
+        $this->themeInstaller = $themeInstaller;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getThemeInstaller()
+    {
+        return $this->themeInstaller;
+    }
+
+    /**
+     * Enable one or more themes.
+     *
+     * @command theme:enable
+     * @param $themes A comma delimited list of themes.
+     * @aliases then,theme-enable
+     */
+    public function enable($themes)
+    {
+        $themes = _convert_csv_to_array($themes);
+        if (!$this->getThemeInstaller()->install($themes, true)) {
+            throw new \Exception('Unable to install themes.');
+        }
+        $this->logger()->success(dt('Successfully enabled theme: !list', ['!list' => implode(', ', $themes)]));
+    }
+
+    /**
+     * Uninstall theme.
+     *
+     * @command theme:uninstall
+     * @param $themes A comma delimited list of themes.
+     * @aliases thun,theme-uninstall
+     */
+    public function uninstall($themes)
+    {
+        $themes = _convert_csv_to_array($themes);
+        if (!$this->getThemeInstaller()->uninstall($themes, true)) {
+            throw new \Exception('Unable to uninstall themes.');
+        }
+        $this->logger()->success(dt('Successfully uninstalled theme: !list', ['!list' => implode(', ', $themes)]));
+        // Our logger got blown away during the container rebuild above.
+        $boot = Drush::bootstrapManager()->bootstrap();
+        $boot->addLogger();
+    }
+}