This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php

38 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2011-05-31 09:57:06 +01:00
/*
2012-03-31 22:00:32 +01:00
* This file is part of the Symfony package.
2011-05-31 09:57:06 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
*
2012-03-31 22:00:32 +01:00
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
2011-05-31 09:57:06 +01:00
*/
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Reference;
/**
* Checks that all references are pointing to a valid service.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass
{
protected function processValue($value, $isRoot = false)
{
if ($value instanceof Reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
$destId = (string) $value;
if (!$this->container->has($destId)) {
throw new ServiceNotFoundException($destId, $this->currentId);
}
}
return parent::processValue($value, $isRoot);
}
2011-06-08 11:16:48 +01:00
}