Mercurial > hg > isophonics-drupal-site
annotate vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
rev | line source |
---|---|
Chris@14 | 1 <?php |
Chris@14 | 2 |
Chris@14 | 3 /* |
Chris@14 | 4 * This file is part of the Symfony package. |
Chris@14 | 5 * |
Chris@14 | 6 * (c) Fabien Potencier <fabien@symfony.com> |
Chris@14 | 7 * |
Chris@14 | 8 * For the full copyright and license information, please view the LICENSE |
Chris@14 | 9 * file that was distributed with this source code. |
Chris@14 | 10 */ |
Chris@14 | 11 |
Chris@14 | 12 namespace Symfony\Component\DependencyInjection\Compiler; |
Chris@14 | 13 |
Chris@14 | 14 use Psr\Container\ContainerInterface; |
Chris@14 | 15 use Symfony\Component\DependencyInjection\Definition; |
Chris@14 | 16 use Symfony\Component\DependencyInjection\Reference; |
Chris@14 | 17 |
Chris@14 | 18 /** |
Chris@14 | 19 * Compiler pass to inject their service locator to service subscribers. |
Chris@14 | 20 * |
Chris@14 | 21 * @author Nicolas Grekas <p@tchwork.com> |
Chris@14 | 22 */ |
Chris@14 | 23 class ResolveServiceSubscribersPass extends AbstractRecursivePass |
Chris@14 | 24 { |
Chris@14 | 25 private $serviceLocator; |
Chris@14 | 26 |
Chris@14 | 27 protected function processValue($value, $isRoot = false) |
Chris@14 | 28 { |
Chris@14 | 29 if ($value instanceof Reference && $this->serviceLocator && ContainerInterface::class === $this->container->normalizeId($value)) { |
Chris@14 | 30 return new Reference($this->serviceLocator); |
Chris@14 | 31 } |
Chris@14 | 32 |
Chris@14 | 33 if (!$value instanceof Definition) { |
Chris@14 | 34 return parent::processValue($value, $isRoot); |
Chris@14 | 35 } |
Chris@14 | 36 |
Chris@14 | 37 $serviceLocator = $this->serviceLocator; |
Chris@16 | 38 $this->serviceLocator = null; |
Chris@16 | 39 |
Chris@16 | 40 if ($value->hasTag('container.service_subscriber.locator')) { |
Chris@16 | 41 $this->serviceLocator = $value->getTag('container.service_subscriber.locator')[0]['id']; |
Chris@16 | 42 $value->clearTag('container.service_subscriber.locator'); |
Chris@16 | 43 } |
Chris@14 | 44 |
Chris@14 | 45 try { |
Chris@14 | 46 return parent::processValue($value); |
Chris@14 | 47 } finally { |
Chris@14 | 48 $this->serviceLocator = $serviceLocator; |
Chris@14 | 49 } |
Chris@14 | 50 } |
Chris@14 | 51 } |