X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FSite%2FMaintenanceCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FSite%2FMaintenanceCommand.php;h=3088e9c3995e77ff9ebe702947270cc96e8ffac6;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Site/MaintenanceCommand.php b/vendor/drupal/console/src/Command/Site/MaintenanceCommand.php new file mode 100644 index 000000000..3088e9c39 --- /dev/null +++ b/vendor/drupal/console/src/Command/Site/MaintenanceCommand.php @@ -0,0 +1,91 @@ +state = $state; + $this->chainQueue = $chainQueue; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('site:maintenance') + ->setDescription($this->trans('commands.site.maintenance.description')) + ->addArgument( + 'mode', + InputArgument::REQUIRED, + $this->trans('commands.site.maintenance.arguments.mode').'[on/off]' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $mode = $input->getArgument('mode'); + $stateName = 'system.maintenance_mode'; + $modeMessage = null; + $cacheRebuild = true; + + if ('ON' === strtoupper($mode)) { + $this->state->set($stateName, true); + $modeMessage = 'commands.site.maintenance.messages.maintenance-on'; + } + if ('OFF' === strtoupper($mode)) { + $this->state->set($stateName, false); + $modeMessage = 'commands.site.maintenance.messages.maintenance-off'; + } + + if ($modeMessage === null) { + $modeMessage = 'commands.site.maintenance.errors.invalid-mode'; + $cacheRebuild = false; + } + + $io->info($this->trans($modeMessage)); + + if ($cacheRebuild) { + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + } + } +}