Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / symfony / dependency-injection / Compiler / CheckExceptionOnInvalidReferenceBehaviorPass.php
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 Symfony\Component\DependencyInjection\ContainerInterface;
15 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
16 use Symfony\Component\DependencyInjection\Reference;
17
18 /**
19  * Checks that all references are pointing to a valid service.
20  *
21  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
22  */
23 class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass
24 {
25     protected function processValue($value, $isRoot = false)
26     {
27         if (!$value instanceof Reference) {
28             return parent::processValue($value, $isRoot);
29         }
30         if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() && !$this->container->has($id = (string) $value)) {
31             throw new ServiceNotFoundException($id, $this->currentId);
32         }
33
34         return $value;
35     }
36 }