/**
  * Run the dispatcher.
  *
  * @param string $args Commands to run
  * @param array $extra Extra parameters
  * @return int Result of the shell process. 1 on success, 0 otherwise.
  */
 public static function run($args, $extra = [])
 {
     static::$_out = '';
     $argv = explode(' ', "dummy-shell.php {$args}");
     $dispatcher = new WebShellDispatcher($argv);
     ob_start();
     $response = $dispatcher->dispatch($extra);
     static::$_out = ob_get_clean();
     return (int) ($response === 0);
 }
 /**
  * Disables the given plugin.
  *
  * @param string $pluginName Plugin's name
  * @return void Redirects to previous page
  */
 public function disable($pluginName)
 {
     $plugin = plugin($pluginName);
     $task = (bool) WebShellDispatcher::run("Installer.plugins toggle -p {$plugin->name} -s disable");
     if ($task) {
         $this->Flash->success(__d('system', 'Plugin was successfully disabled!'));
     } else {
         $this->Flash->set(__d('system', 'Plugin could not be disabled'), ['element' => 'System.installer_errors', 'params' => ['errors' => WebShellDispatcher::output()]]);
     }
     $this->title(__d('system', 'Disable Plugin'));
     header('Location:' . $this->referer());
     exit;
 }
 /**
  * Marks as active the provided theme.
  *
  * @param string $themeName Theme's name
  * @return void
  */
 public function activate($themeName)
 {
     $theme = plugin($themeName);
     // throws
     if (!in_array($themeName, [option('front_theme'), option('back_theme')])) {
         $task = (bool) WebShellDispatcher::run("Installer.themes change -t {$theme->name}");
         if ($task) {
             $this->Flash->success(__d('system', 'Theme successfully activated!'));
         } else {
             $this->Flash->set(__d('system', 'Theme could not be activated'), ['element' => 'System.installer_errors', 'params' => ['errors' => WebShellDispatcher::output()]]);
         }
     } else {
         $this->Flash->danger(__d('system', 'This theme is already active.'));
     }
     $this->title(__d('system', 'Activate Theme'));
     $this->redirect($this->referer());
 }