mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
Package operations: 2 installs, 23 updates, 0 removals - Updating psr/log (1.1.0 => 1.1.2) - Updating symfony/debug (v3.4.30 => v3.4.35) - Updating symfony/console (v3.4.30 => v3.4.35) - Updating symfony/dotenv (v3.4.30 => v3.4.35) - Updating symfony/routing (v3.4.30 => v3.4.35) - Updating symfony/finder (v3.4.30 => v3.4.35) - Updating symfony/filesystem (v3.4.30 => v3.4.35) - Installing symfony/polyfill-util (v1.12.0) - Installing symfony/polyfill-php56 (v1.12.0) - Updating symfony/http-foundation (v3.4.30 => v3.4.35) - Updating symfony/event-dispatcher (v3.4.30 => v3.4.35) - Updating symfony/http-kernel (v3.4.30 => v3.4.35) - Updating symfony/config (v3.4.30 => v3.4.35) - Updating symfony/dependency-injection (v3.4.30 => v3.4.35) - Updating symfony/class-loader (v3.4.30 => v3.4.35) - Updating symfony/cache (v3.4.30 => v3.4.35) - Updating symfony/framework-bundle (v3.4.30 => v3.4.35) - Updating twig/twig (v1.42.2 => v1.42.4) - Updating symfony/twig-bridge (v3.4.30 => v3.4.35) - Updating symfony/twig-bundle (v3.4.30 => v3.4.35) - Updating symfony/yaml (v3.4.30 => v3.4.35) - Updating symfony/stopwatch (v3.4.30 => v3.4.35) - Updating symfony/var-dumper (v3.4.30 => v3.4.35) - Updating symfony/web-profiler-bundle (v3.4.30 => v3.4.35) - Updating symfony/css-selector (v3.4.30 => v3.4.35)
136 lines
4.7 KiB
PHP
136 lines
4.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Command;
|
|
|
|
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
|
|
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
|
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
/**
|
|
* A console command for dumping available configuration reference.
|
|
*
|
|
* @author Kevin Bond <kevinbond@gmail.com>
|
|
* @author Wouter J <waldio.webdesign@gmail.com>
|
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
|
*
|
|
* @final since version 3.4
|
|
*/
|
|
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
|
{
|
|
protected static $defaultName = 'config:dump-reference';
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setDefinition([
|
|
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
|
|
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
|
|
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'),
|
|
])
|
|
->setDescription('Dumps the default configuration for an extension')
|
|
->setHelp(<<<'EOF'
|
|
The <info>%command.name%</info> command dumps the default configuration for an
|
|
extension/bundle.
|
|
|
|
Either the extension alias or bundle name can be used:
|
|
|
|
<info>php %command.full_name% framework</info>
|
|
<info>php %command.full_name% FrameworkBundle</info>
|
|
|
|
With the <info>--format</info> option specifies the format of the configuration,
|
|
this is either <comment>yaml</comment> or <comment>xml</comment>.
|
|
When the option is not provided, <comment>yaml</comment> is used.
|
|
|
|
<info>php %command.full_name% FrameworkBundle --format=xml</info>
|
|
|
|
For dumping a specific option, add its path as second argument (only available for the yaml format):
|
|
|
|
<info>php %command.full_name% framework profiler.matcher</info>
|
|
|
|
EOF
|
|
)
|
|
;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \LogicException
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
$errorIo = $io->getErrorStyle();
|
|
|
|
if (null === $name = $input->getArgument('name')) {
|
|
$this->listBundles($errorIo);
|
|
$errorIo->comment([
|
|
'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)',
|
|
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
|
|
]);
|
|
|
|
return null;
|
|
}
|
|
|
|
$extension = $this->findExtension($name);
|
|
|
|
$configuration = $extension->getConfiguration([], $this->getContainerBuilder());
|
|
|
|
$this->validateConfiguration($extension, $configuration);
|
|
|
|
$format = $input->getOption('format');
|
|
$path = $input->getArgument('path');
|
|
|
|
if (null !== $path && 'yaml' !== $format) {
|
|
$errorIo->error('The "path" option is only available for the "yaml" format.');
|
|
|
|
return 1;
|
|
}
|
|
|
|
if ($name === $extension->getAlias()) {
|
|
$message = sprintf('Default configuration for extension with alias: "%s"', $name);
|
|
} else {
|
|
$message = sprintf('Default configuration for "%s"', $name);
|
|
}
|
|
|
|
if (null !== $path) {
|
|
$message .= sprintf(' at path "%s"', $path);
|
|
}
|
|
|
|
switch ($format) {
|
|
case 'yaml':
|
|
$io->writeln(sprintf('# %s', $message));
|
|
$dumper = new YamlReferenceDumper();
|
|
break;
|
|
case 'xml':
|
|
$io->writeln(sprintf('<!-- %s -->', $message));
|
|
$dumper = new XmlReferenceDumper();
|
|
break;
|
|
default:
|
|
$io->writeln($message);
|
|
throw new InvalidArgumentException('Only the yaml and xml formats are supported.');
|
|
}
|
|
|
|
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));
|
|
|
|
return null;
|
|
}
|
|
}
|