. * --------------------------------------------------------------------- */ namespace Glpi\Console\Maintenance; if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } use Config; use Glpi\Console\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class EnableMaintenanceModeCommand extends AbstractCommand { protected function configure() { parent::configure(); $this->setName('glpi:maintenance:enable'); $this->setAliases( [ 'maintenance:enable', ] ); $this->setDescription(__('Enable maintenance mode')); $this->addOption( 'text', 't', InputOption::VALUE_OPTIONAL, __('Text to display during maintenance') ); } protected function execute(InputInterface $input, OutputInterface $output) { global $CFG_GLPI; $values = [ 'maintenance_mode' => '1' ]; if ($input->hasOption('text')) { $values['maintenance_text'] = $input->getOption('text'); } $config = new Config(); $config->setConfigurationValues('core', $values); $message = sprintf( __('Maintenance mode activated. Backdoor using: %s'), $CFG_GLPI['url_base'] . '/index.php?skipMaintenance=1' ); $output->writeln('' . $message . ''); return 0; // Success } }