comparison vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.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 c2387f117808
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 Psr\Container\ContainerInterface;
15 use Symfony\Component\DependencyInjection\Definition;
16 use Symfony\Component\DependencyInjection\Reference;
17
18 /**
19 * Compiler pass to inject their service locator to service subscribers.
20 *
21 * @author Nicolas Grekas <p@tchwork.com>
22 */
23 class ResolveServiceSubscribersPass extends AbstractRecursivePass
24 {
25 private $serviceLocator;
26
27 protected function processValue($value, $isRoot = false)
28 {
29 if ($value instanceof Reference && $this->serviceLocator && ContainerInterface::class === $this->container->normalizeId($value)) {
30 return new Reference($this->serviceLocator);
31 }
32
33 if (!$value instanceof Definition) {
34 return parent::processValue($value, $isRoot);
35 }
36
37 $serviceLocator = $this->serviceLocator;
38 $this->serviceLocator = $value->hasTag('container.service_subscriber.locator') ? $value->getTag('container.service_subscriber.locator')[0]['id'] : null;
39
40 try {
41 return parent::processValue($value);
42 } finally {
43 $this->serviceLocator = $serviceLocator;
44 }
45 }
46 }