- md5
- acf664feb1356ffc7a6825b14a3cc01d
- sha1
- 575721fa6a5dcb4a42ce782c2b2bdd22ca50b189
- sha256
- c41d4d12a36afaa2202fe0ef30e0ad55de501d052d8e5d0ab0280a30479b158c
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('Put 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.