mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 18:18:46 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -14,6 +14,7 @@ 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\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
@@ -22,8 +23,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -35,24 +34,21 @@ use Symfony\Component\Yaml\Yaml;
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
#[AsCommand(name: 'config:dump-reference', description: 'Dump the default configuration for an extension')]
|
||||
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
||||
{
|
||||
protected static $defaultName = 'config:dump-reference';
|
||||
protected static $defaultDescription = 'Dump the default configuration for an extension';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
protected function configure(): void
|
||||
{
|
||||
$commentedHelpFormats = array_map(fn ($format) => sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
|
||||
$helpFormats = implode('", "', $commentedHelpFormats);
|
||||
|
||||
$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'),
|
||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'yaml'),
|
||||
])
|
||||
->setDescription(self::$defaultDescription)
|
||||
->setHelp(<<<'EOF'
|
||||
->setHelp(<<<EOF
|
||||
The <info>%command.name%</info> command dumps the default configuration for an
|
||||
extension/bundle.
|
||||
|
||||
@@ -61,9 +57,8 @@ 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.
|
||||
The <info>--format</info> option specifies the format of the configuration,
|
||||
these are "{$helpFormats}".
|
||||
|
||||
<info>php %command.full_name% FrameworkBundle --format=xml</info>
|
||||
|
||||
@@ -77,8 +72,6 @@ EOF
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
@@ -88,14 +81,7 @@ EOF
|
||||
|
||||
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()]]);
|
||||
}
|
||||
$this->listNonBundleExtensions($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>)',
|
||||
@@ -152,7 +138,7 @@ EOF
|
||||
break;
|
||||
default:
|
||||
$io->writeln($message);
|
||||
throw new InvalidArgumentException('Only the yaml and xml formats are supported.');
|
||||
throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions())));
|
||||
}
|
||||
|
||||
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));
|
||||
@@ -163,6 +149,7 @@ EOF
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestArgumentValuesFor('name')) {
|
||||
$suggestions->suggestValues($this->getAvailableExtensions());
|
||||
$suggestions->suggestValues($this->getAvailableBundles());
|
||||
}
|
||||
|
||||
@@ -171,13 +158,24 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function getAvailableExtensions(): array
|
||||
{
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
|
||||
$extensions = [];
|
||||
foreach ($this->getContainerBuilder($kernel)->getExtensions() as $alias => $extension) {
|
||||
$extensions[] = $alias;
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
private function getAvailableBundles(): array
|
||||
{
|
||||
$bundles = [];
|
||||
|
||||
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
|
||||
$bundles[] = $bundle->getName();
|
||||
$bundles[] = $bundle->getContainerExtension()->getAlias();
|
||||
}
|
||||
|
||||
return $bundles;
|
||||
|
||||
Reference in New Issue
Block a user