- md5
- 4abcc65ed0f1f7833b867554977e15bb
- sha1
- 741051f057fea289d1a2fe36ee5a87493d0ca75d
- sha256
- 062e68ecab559c00c47a89b74e4afb8ef584265456aa24382ed3906309a1e994
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Console;
defined('JPATH_PLATFORM') or die;
use Joomla\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Console command wrapper for getting the site into offline mode
*
* @since 4.0.0
*/
class SiteDownCommand extends AbstractCommand
{
/**
* The default command name
*
* @var string
* @since 4.0
*/
protected static $defaultName = 'site:down';
/**
* SymfonyStyle Object
* @var SymfonyStyle
* @since 4.0
*/
private $ioStyle;
/**
* Return code if site:down failed
* @since 4.0
*/
const SITE_DOWN_FAILED = 1;
/**
* Return code if site:down was successful
* @since 4.0
*/
const SITE_DOWN_SUCCESSFUL = 0;
/**
* Configures the IO
*
* @param InputInterface $input Console Input
* @param OutputInterface $output Console Output
*
* @return void
*
* @since 4.0
*
*/
private function configureIO(InputInterface $input, OutputInterface $output)
{
$this->ioStyle = new SymfonyStyle($input, $output);
}
/**
* Initialise the command.
*
* @return void
*
* @since 4.0.0
*/
protected function configure(): void
{
$this->setDescription('Puts the site into offline mode');
$help = <<<'EOF'
The <info>%command.name%</info> is used to place the site offline.
<info>php %command.full_name%</info>
EOF;
$this->setHelp($help);
}
/**
* Internal function to execute the command.
*
* @param InputInterface $input The input to inject into the command.
* @param OutputInterface $output The output to inject into the command.
*
* @return integer The command exit code
*
* @since 4.0.0
*/
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$this->configureIO($input, $output);
$returnCode = $this->getApplication()->getCommand(SetConfigurationCommand::getDefaultName())->execute(
new ArrayInput(['options' => ['offline=true']]), $output
);
if ($returnCode === 0)
{
$this->ioStyle->success("Successfully set site to offline");
return self::SITE_DOWN_SUCCESSFUL;
}
return self::SITE_DOWN_FAILED;
}
}
No other release has this exact content. See every version of this file.