annotate vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\DependencyInjection\Compiler;
Chris@0 13
Chris@17 14 use Symfony\Component\DependencyInjection\ContainerInterface;
Chris@0 15 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
Chris@0 16 use Symfony\Component\DependencyInjection\Reference;
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Checks that all references are pointing to a valid service.
Chris@0 20 *
Chris@0 21 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
Chris@0 22 */
Chris@14 23 class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass
Chris@0 24 {
Chris@14 25 protected function processValue($value, $isRoot = false)
Chris@14 26 {
Chris@14 27 if (!$value instanceof Reference) {
Chris@14 28 return parent::processValue($value, $isRoot);
Chris@14 29 }
Chris@14 30 if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() && !$this->container->has($id = (string) $value)) {
Chris@14 31 throw new ServiceNotFoundException($id, $this->currentId);
Chris@14 32 }
Chris@0 33
Chris@14 34 return $value;
Chris@0 35 }
Chris@0 36 }