5 * Contains \Drupal\Console\Command\Site\MaintenanceCommand.
8 namespace Drupal\Console\Command\Site;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Core\Command\ContainerAwareCommand;
14 use Drupal\Core\State\StateInterface;
15 use Drupal\Console\Core\Utils\ChainQueue;
17 class MaintenanceCommand extends ContainerAwareCommand
28 protected $chainQueue;
31 * DebugCommand constructor.
33 * @param StateInterface $state
34 * @param ChainQueue $chainQueue
36 public function __construct(
37 StateInterface $state,
38 ChainQueue $chainQueue
40 $this->state = $state;
41 $this->chainQueue = $chainQueue;
42 parent::__construct();
45 protected function configure()
48 ->setName('site:maintenance')
49 ->setDescription($this->trans('commands.site.maintenance.description'))
52 InputArgument::REQUIRED,
53 $this->trans('commands.site.maintenance.arguments.mode')
55 ->setAliases(['sma']);
58 protected function execute(InputInterface $input, OutputInterface $output)
60 $mode = $input->getArgument('mode');
61 $stateName = 'system.maintenance_mode';
65 if ('ON' === strtoupper($mode)) {
66 $this->state->set($stateName, true);
67 $modeMessage = 'commands.site.maintenance.messages.maintenance-on';
69 if ('OFF' === strtoupper($mode)) {
70 $this->state->set($stateName, false);
71 $modeMessage = 'commands.site.maintenance.messages.maintenance-off';
74 if ($modeMessage === null) {
75 $modeMessage = 'commands.site.maintenance.errors.invalid-mode';
76 $cacheRebuild = false;
79 $this->getIo()->info($this->trans($modeMessage));
82 $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);