4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Compiler;
14 use Symfony\Component\DependencyInjection\ContainerInterface;
15 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
16 use Symfony\Component\DependencyInjection\Reference;
19 * Checks that all references are pointing to a valid service.
21 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
23 class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass
25 protected function processValue($value, $isRoot = false)
27 if (!$value instanceof Reference) {
28 return parent::processValue($value, $isRoot);
30 if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() && !$this->container->has($id = (string) $value)) {
31 throw new ServiceNotFoundException($id, $this->currentId);