mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +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:
@@ -29,18 +29,16 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
abstract class AbstractConfigCommand extends ContainerDebugCommand
|
||||
{
|
||||
/**
|
||||
* @param OutputInterface|StyleInterface $output
|
||||
* @return void
|
||||
*/
|
||||
protected function listBundles($output)
|
||||
protected function listBundles(OutputInterface|StyleInterface $output)
|
||||
{
|
||||
$title = 'Available registered bundles with their extension alias if available';
|
||||
$headers = ['Bundle name', 'Extension alias'];
|
||||
$rows = [];
|
||||
|
||||
$bundles = $this->getApplication()->getKernel()->getBundles();
|
||||
usort($bundles, function ($bundleA, $bundleB) {
|
||||
return strcmp($bundleA->getName(), $bundleB->getName());
|
||||
});
|
||||
usort($bundles, fn ($bundleA, $bundleB) => strcmp($bundleA->getName(), $bundleB->getName()));
|
||||
|
||||
foreach ($bundles as $bundle) {
|
||||
$extension = $bundle->getContainerExtension();
|
||||
@@ -57,10 +55,45 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ExtensionInterface
|
||||
*/
|
||||
protected function findExtension(string $name)
|
||||
protected function listNonBundleExtensions(OutputInterface|StyleInterface $output): void
|
||||
{
|
||||
$title = 'Available registered non-bundle extension aliases';
|
||||
$headers = ['Extension alias'];
|
||||
$rows = [];
|
||||
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
|
||||
$bundleExtensions = [];
|
||||
foreach ($kernel->getBundles() as $bundle) {
|
||||
if ($extension = $bundle->getContainerExtension()) {
|
||||
$bundleExtensions[$extension::class] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$extensions = $this->getContainerBuilder($kernel)->getExtensions();
|
||||
|
||||
foreach ($extensions as $alias => $extension) {
|
||||
if (isset($bundleExtensions[$extension::class])) {
|
||||
continue;
|
||||
}
|
||||
$rows[] = [$alias];
|
||||
}
|
||||
|
||||
if (!$rows) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($output instanceof StyleInterface) {
|
||||
$output->title($title);
|
||||
$output->table($headers, $rows);
|
||||
} else {
|
||||
$output->writeln($title);
|
||||
$table = new Table($output);
|
||||
$table->setHeaders($headers)->setRows($rows)->render();
|
||||
}
|
||||
}
|
||||
|
||||
protected function findExtension(string $name): ExtensionInterface
|
||||
{
|
||||
$bundles = $this->initializeBundles();
|
||||
$minScore = \INF;
|
||||
@@ -126,7 +159,10 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
||||
throw new LogicException($message);
|
||||
}
|
||||
|
||||
public function validateConfiguration(ExtensionInterface $extension, $configuration)
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function validateConfiguration(ExtensionInterface $extension, mixed $configuration)
|
||||
{
|
||||
if (!$configuration) {
|
||||
throw new \LogicException(sprintf('The extension with alias "%s" does not have its getConfiguration() method setup.', $extension->getAlias()));
|
||||
@@ -137,7 +173,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
||||
}
|
||||
}
|
||||
|
||||
private function initializeBundles()
|
||||
private function initializeBundles(): array
|
||||
{
|
||||
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
|
||||
// as this method is not called when the container is loaded from the cache.
|
||||
|
||||
Reference in New Issue
Block a user