mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 20:48:46 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,14 +11,20 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
|
||||
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
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;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* A console command for dumping available configuration reference.
|
||||
@@ -27,11 +33,12 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
* @author Wouter J <waldio.webdesign@gmail.com>
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*
|
||||
* @final since version 3.4
|
||||
* @final
|
||||
*/
|
||||
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
||||
{
|
||||
protected static $defaultName = 'config:dump-reference';
|
||||
protected static $defaultDescription = 'Dump the default configuration for an extension';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -44,7 +51,7 @@ class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
||||
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')
|
||||
->setDescription(self::$defaultDescription)
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command dumps the default configuration for an
|
||||
extension/bundle.
|
||||
@@ -74,28 +81,48 @@ EOF
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$errorIo = $io->getErrorStyle();
|
||||
|
||||
if (null === $name = $input->getArgument('name')) {
|
||||
$this->listBundles($errorIo);
|
||||
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
if ($kernel instanceof ExtensionInterface
|
||||
&& ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)
|
||||
&& $kernel->getAlias()
|
||||
) {
|
||||
$errorIo->table(['Kernel Extension'], [[$kernel->getAlias()]]);
|
||||
}
|
||||
|
||||
$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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$extension = $this->findExtension($name);
|
||||
|
||||
$configuration = $extension->getConfiguration([], $this->getContainerBuilder());
|
||||
if ($extension instanceof ConfigurationInterface) {
|
||||
$configuration = $extension;
|
||||
} else {
|
||||
$configuration = $extension->getConfiguration([], $this->getContainerBuilder($this->getApplication()->getKernel()));
|
||||
}
|
||||
|
||||
$this->validateConfiguration($extension, $configuration);
|
||||
|
||||
$format = $input->getOption('format');
|
||||
|
||||
if ('yaml' === $format && !class_exists(Yaml::class)) {
|
||||
$errorIo->error('Setting the "format" option to "yaml" requires the Symfony Yaml component. Try running "composer install symfony/yaml" or use "--format=xml" instead.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$path = $input->getArgument('path');
|
||||
|
||||
if (null !== $path && 'yaml' !== $format) {
|
||||
@@ -130,6 +157,34 @@ EOF
|
||||
|
||||
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));
|
||||
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestArgumentValuesFor('name')) {
|
||||
$suggestions->suggestValues($this->getAvailableBundles());
|
||||
}
|
||||
|
||||
if ($input->mustSuggestOptionValuesFor('format')) {
|
||||
$suggestions->suggestValues($this->getAvailableFormatOptions());
|
||||
}
|
||||
}
|
||||
|
||||
private function getAvailableBundles(): array
|
||||
{
|
||||
$bundles = [];
|
||||
|
||||
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
|
||||
$bundles[] = $bundle->getName();
|
||||
$bundles[] = $bundle->getContainerExtension()->getAlias();
|
||||
}
|
||||
|
||||
return $bundles;
|
||||
}
|
||||
|
||||
private function getAvailableFormatOptions(): array
|
||||
{
|
||||
return ['yaml', 'xml'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user