Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Cron / ExecuteCommand.php
index 39181925ca5dad03948d7eb1ab49c169ad3d9607..5fd9344636fb2092e751b8fa3a9e21b9bd47b2b2 100644 (file)
@@ -10,18 +10,13 @@ namespace Drupal\Console\Command\Cron;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Lock\LockBackendInterface;
 use Drupal\Core\State\StateInterface;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
-use Drupal\Console\Core\Utils\ChainQueue;
 
 class ExecuteCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var ModuleHandlerInterface
      */
@@ -37,29 +32,21 @@ class ExecuteCommand extends Command
      */
     protected $state;
 
-    /**
-     * @var ChainQueue
-     */
-    protected $chainQueue;
-
     /**
      * DebugCommand constructor.
      *
      * @param ModuleHandlerInterface $moduleHandler
      * @param LockBackendInterface   $lock
      * @param StateInterface         $state
-     * @param ChainQueue             $chainQueue
      */
     public function __construct(
         ModuleHandlerInterface $moduleHandler,
         LockBackendInterface $lock,
-        StateInterface $state,
-        ChainQueue $chainQueue
+        StateInterface $state
     ) {
         $this->moduleHandler = $moduleHandler;
         $this->lock = $lock;
         $this->state = $state;
-        $this->chainQueue = $chainQueue;
         parent::__construct();
     }
 
@@ -75,7 +62,8 @@ class ExecuteCommand extends Command
                 'module',
                 InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
                 $this->trans('commands.common.options.module')
-            );
+            )
+            ->setAliases(['croe']);
     }
 
     /**
@@ -83,11 +71,10 @@ class ExecuteCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
         $modules = $input->getArgument('module');
 
         if (!$this->lock->acquire('cron', 900.0)) {
-            $io->warning($this->trans('commands.cron.execute.messages.lock'));
+            $this->getIo()->warning($this->trans('commands.cron.execute.messages.lock'));
 
             return 1;
         }
@@ -98,7 +85,7 @@ class ExecuteCommand extends Command
 
         foreach ($modules as $module) {
             if (!$this->moduleHandler->implementsHook($module, 'cron')) {
-                $io->warning(
+                $this->getIo()->warning(
                     sprintf(
                         $this->trans('commands.cron.execute.messages.module-invalid'),
                         $module
@@ -107,7 +94,7 @@ class ExecuteCommand extends Command
                 continue;
             }
             try {
-                $io->info(
+                $this->getIo()->info(
                     sprintf(
                         $this->trans('commands.cron.execute.messages.executing-cron'),
                         $module
@@ -116,16 +103,14 @@ class ExecuteCommand extends Command
                 $this->moduleHandler->invoke($module, 'cron');
             } catch (\Exception $e) {
                 watchdog_exception('cron', $e);
-                $io->error($e->getMessage());
+                $this->getIo()->error($e->getMessage());
             }
         }
 
         $this->state->set('system.cron_last', REQUEST_TIME);
         $this->lock->release('cron');
 
-        $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
-
-        $io->success($this->trans('commands.cron.execute.messages.success'));
+        $this->getIo()->success($this->trans('commands.cron.execute.messages.success'));
 
         return 0;
     }