mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 13:08:45 +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:
@@ -17,43 +17,19 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
|
||||
{
|
||||
private $tagName;
|
||||
protected bool $skipScalars = true;
|
||||
|
||||
private $aliases = [];
|
||||
private array $aliases = [];
|
||||
|
||||
public function __construct(string $tagName = 'container.private')
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (0 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/dependency-injection', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
|
||||
}
|
||||
|
||||
$this->tagName = $tagName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function processValue($value, bool $isRoot = false)
|
||||
{
|
||||
if ($value instanceof Reference && isset($this->aliases[$id = (string) $value])) {
|
||||
return new Reference($this->aliases[$id], $value->getInvalidBehavior());
|
||||
}
|
||||
|
||||
return parent::processValue($value, $isRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
foreach ($container->findTaggedServiceIds($this->tagName) as $id => $tags) {
|
||||
foreach ($container->findTaggedServiceIds('container.private') as $id => $tags) {
|
||||
if (null === $package = $tags[0]['package'] ?? null) {
|
||||
throw new InvalidArgumentException(sprintf('The "package" attribute is mandatory for the "%s" tag on the "%s" service.', $this->tagName, $id));
|
||||
throw new InvalidArgumentException(sprintf('The "package" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
|
||||
}
|
||||
|
||||
if (null === $version = $tags[0]['version'] ?? null) {
|
||||
throw new InvalidArgumentException(sprintf('The "version" attribute is mandatory for the "%s" tag on the "%s" service.', $this->tagName, $id));
|
||||
throw new InvalidArgumentException(sprintf('The "version" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition($id);
|
||||
@@ -62,7 +38,7 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
$container
|
||||
->setAlias($id, $aliasId = '.'.$this->tagName.'.'.$id)
|
||||
->setAlias($id, $aliasId = '.container.private.'.$id)
|
||||
->setPublic(true)
|
||||
->setDeprecated($package, $version, 'Accessing the "%alias_id%" service directly from the container is deprecated, use dependency injection instead.');
|
||||
|
||||
@@ -73,4 +49,13 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
|
||||
|
||||
parent::process($container);
|
||||
}
|
||||
|
||||
protected function processValue(mixed $value, bool $isRoot = false): mixed
|
||||
{
|
||||
if ($value instanceof Reference && isset($this->aliases[$id = (string) $value])) {
|
||||
return new Reference($this->aliases[$id], $value->getInvalidBehavior());
|
||||
}
|
||||
|
||||
return parent::processValue($value, $isRoot);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user