comparison vendor/symfony/dependency-injection/Compiler/ResolveHotPathPass.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\DependencyInjection\Compiler;
13
14 use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Definition;
17 use Symfony\Component\DependencyInjection\Reference;
18
19 /**
20 * Propagate "container.hot_path" tags to referenced services.
21 *
22 * @author Nicolas Grekas <p@tchwork.com>
23 */
24 class ResolveHotPathPass extends AbstractRecursivePass
25 {
26 private $tagName;
27 private $resolvedIds = array();
28
29 public function __construct($tagName = 'container.hot_path')
30 {
31 $this->tagName = $tagName;
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function process(ContainerBuilder $container)
38 {
39 try {
40 parent::process($container);
41 $container->getDefinition('service_container')->clearTag($this->tagName);
42 } finally {
43 $this->resolvedIds = array();
44 }
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 protected function processValue($value, $isRoot = false)
51 {
52 if ($value instanceof ArgumentInterface) {
53 return $value;
54 }
55 if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) {
56 return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value;
57 }
58 if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = $this->container->normalizeId($value))) {
59 $definition = $this->container->findDefinition($id);
60 if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) {
61 $this->resolvedIds[$id] = true;
62 $definition->addTag($this->tagName);
63 parent::processValue($definition, false);
64 }
65
66 return $value;
67 }
68
69 return parent::processValue($value, $isRoot);
70 }
71 }