Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/DecoratorServicePass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
9 * file that was distributed with this source code. | 9 * file that was distributed with this source code. |
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\DependencyInjection\Compiler; | 12 namespace Symfony\Component\DependencyInjection\Compiler; |
13 | 13 |
14 use Symfony\Component\DependencyInjection\Alias; | |
14 use Symfony\Component\DependencyInjection\ContainerBuilder; | 15 use Symfony\Component\DependencyInjection\ContainerBuilder; |
15 use Symfony\Component\DependencyInjection\Alias; | |
16 | 16 |
17 /** | 17 /** |
18 * Overwrites a service but keeps the overridden one. | 18 * Overwrites a service but keeps the overridden one. |
19 * | 19 * |
20 * @author Christophe Coevoet <stof@notk.org> | 20 * @author Christophe Coevoet <stof@notk.org> |
30 | 30 |
31 foreach ($container->getDefinitions() as $id => $definition) { | 31 foreach ($container->getDefinitions() as $id => $definition) { |
32 if (!$decorated = $definition->getDecoratedService()) { | 32 if (!$decorated = $definition->getDecoratedService()) { |
33 continue; | 33 continue; |
34 } | 34 } |
35 $definitions->insert(array($id, $definition), array($decorated[2], --$order)); | 35 $definitions->insert([$id, $definition], [$decorated[2], --$order]); |
36 } | 36 } |
37 $decoratingDefinitions = []; | |
37 | 38 |
38 foreach ($definitions as list($id, $definition)) { | 39 foreach ($definitions as list($id, $definition)) { |
39 list($inner, $renamedId) = $definition->getDecoratedService(); | 40 list($inner, $renamedId) = $definition->getDecoratedService(); |
40 | 41 |
41 $definition->setDecoratedService(null); | 42 $definition->setDecoratedService(null); |
51 $public = $alias->isPublic(); | 52 $public = $alias->isPublic(); |
52 $private = $alias->isPrivate(); | 53 $private = $alias->isPrivate(); |
53 $container->setAlias($renamedId, new Alias($container->normalizeId($alias), false)); | 54 $container->setAlias($renamedId, new Alias($container->normalizeId($alias), false)); |
54 } else { | 55 } else { |
55 $decoratedDefinition = $container->getDefinition($inner); | 56 $decoratedDefinition = $container->getDefinition($inner); |
56 $definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags())); | |
57 if ($types = array_merge($decoratedDefinition->getAutowiringTypes(false), $definition->getAutowiringTypes(false))) { | |
58 $definition->setAutowiringTypes($types); | |
59 } | |
60 $public = $decoratedDefinition->isPublic(); | 57 $public = $decoratedDefinition->isPublic(); |
61 $private = $decoratedDefinition->isPrivate(); | 58 $private = $decoratedDefinition->isPrivate(); |
62 $decoratedDefinition->setPublic(false); | 59 $decoratedDefinition->setPublic(false); |
63 $decoratedDefinition->setTags(array()); | 60 $container->setDefinition($renamedId, $decoratedDefinition); |
64 if ($decoratedDefinition->getAutowiringTypes(false)) { | 61 $decoratingDefinitions[$inner] = $decoratedDefinition; |
65 $decoratedDefinition->setAutowiringTypes(array()); | 62 } |
63 | |
64 if (isset($decoratingDefinitions[$inner])) { | |
65 $decoratingDefinition = $decoratingDefinitions[$inner]; | |
66 $definition->setTags(array_merge($decoratingDefinition->getTags(), $definition->getTags())); | |
67 $autowiringTypes = $decoratingDefinition->getAutowiringTypes(false); | |
68 if ($types = array_merge($autowiringTypes, $definition->getAutowiringTypes(false))) { | |
69 $definition->setAutowiringTypes($types); | |
66 } | 70 } |
67 $container->setDefinition($renamedId, $decoratedDefinition); | 71 $decoratingDefinition->setTags([]); |
72 if ($autowiringTypes) { | |
73 $decoratingDefinition->setAutowiringTypes([]); | |
74 } | |
75 $decoratingDefinitions[$inner] = $definition; | |
68 } | 76 } |
69 | 77 |
70 $container->setAlias($inner, $id)->setPublic($public)->setPrivate($private); | 78 $container->setAlias($inner, $id)->setPublic($public)->setPrivate($private); |
71 } | 79 } |
72 } | 80 } |