mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +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:
@@ -30,9 +30,11 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass
|
||||
parent::process($container);
|
||||
|
||||
foreach ($container->getAliases() as $id => $alias) {
|
||||
$aliasId = $container->normalizeId($alias);
|
||||
$aliasId = (string) $alias;
|
||||
$this->currentId = $id;
|
||||
|
||||
if ($aliasId !== $defId = $this->getDefinitionId($aliasId, $container)) {
|
||||
$container->setAlias($id, $defId)->setPublic($alias->isPublic())->setPrivate($alias->isPrivate());
|
||||
$container->setAlias($id, $defId)->setPublic($alias->isPublic());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,36 +42,42 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function processValue($value, $isRoot = false)
|
||||
protected function processValue($value, bool $isRoot = false)
|
||||
{
|
||||
if ($value instanceof Reference) {
|
||||
$defId = $this->getDefinitionId($id = $this->container->normalizeId($value), $this->container);
|
||||
if (!$value instanceof Reference) {
|
||||
return parent::processValue($value, $isRoot);
|
||||
}
|
||||
|
||||
if ($defId !== $id) {
|
||||
return new Reference($defId, $value->getInvalidBehavior());
|
||||
$defId = $this->getDefinitionId($id = (string) $value, $this->container);
|
||||
|
||||
return $defId !== $id ? new Reference($defId, $value->getInvalidBehavior()) : $value;
|
||||
}
|
||||
|
||||
private function getDefinitionId(string $id, ContainerBuilder $container): string
|
||||
{
|
||||
if (!$container->hasAlias($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
$alias = $container->getAlias($id);
|
||||
|
||||
if ($alias->isDeprecated()) {
|
||||
$referencingDefinition = $container->hasDefinition($this->currentId) ? $container->getDefinition($this->currentId) : $container->getAlias($this->currentId);
|
||||
if (!$referencingDefinition->isDeprecated()) {
|
||||
$deprecation = $alias->getDeprecation($id);
|
||||
trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::processValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an alias into a definition id.
|
||||
*
|
||||
* @param string $id The definition or alias id to resolve
|
||||
*
|
||||
* @return string The definition id with aliases resolved
|
||||
*/
|
||||
private function getDefinitionId($id, ContainerBuilder $container)
|
||||
{
|
||||
$seen = [];
|
||||
while ($container->hasAlias($id)) {
|
||||
do {
|
||||
if (isset($seen[$id])) {
|
||||
throw new ServiceCircularReferenceException($id, array_merge(array_keys($seen), [$id]));
|
||||
}
|
||||
|
||||
$seen[$id] = true;
|
||||
$id = $container->normalizeId($container->getAlias($id));
|
||||
}
|
||||
$id = (string) $container->getAlias($id);
|
||||
} while ($container->hasAlias($id));
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user