[FEATURE] Add commands for listing and showing sites
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Command / SiteShowCommand.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Core\Command;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use Symfony\Component\Console\Command\Command;
20 use Symfony\Component\Console\Input\InputArgument;
21 use Symfony\Component\Console\Input\InputInterface;
22 use Symfony\Component\Console\Output\OutputInterface;
23 use Symfony\Component\Console\Style\SymfonyStyle;
24 use Symfony\Component\Yaml\Yaml;
25 use TYPO3\CMS\Core\Site\SiteFinder;
26
27 /**
28 * Command for showing the configuration of a site
29 */
30 class SiteShowCommand extends Command
31 {
32 /**
33 * Defines the allowed options for this command
34 */
35 protected function configure()
36 {
37 $this->setDescription('Shows the configuration of the specified site. Specify the identifier via "site:show <identifier>".')
38 ->addArgument(
39 'identifier',
40 InputArgument::REQUIRED,
41 'The identifier of the site'
42 );
43 }
44
45 /**
46 * Shows the configuration of a site
47 *
48 * @inheritdoc
49 */
50 protected function execute(InputInterface $input, OutputInterface $output)
51 {
52 $io = new SymfonyStyle($input, $output);
53 $siteFinder = new SiteFinder();
54 $site = $siteFinder->getSiteByIdentifier($input->getArgument('identifier'));
55 $io->title('Site configuration for ' . $input->getArgument('identifier'));
56 $io->block(Yaml::dump($site->getConfiguration(), 4));
57 }
58 }