[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
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\Definition; 15 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; 16 use Symfony\Component\DependencyInjection\ContainerInterface; 17 use Symfony\Component\DependencyInjection\Reference; 18 use Symfony\Component\DependencyInjection\ContainerBuilder; 19 20 /** 21 * Checks that all references are pointing to a valid service. 22 * 23 * @author Johannes M. Schmitt <schmittjoh@gmail.com> 24 */ 25 class CheckExceptionOnInvalidReferenceBehaviorPass implements CompilerPassInterface 26 { 27 private $container; 28 private $sourceId; 29 30 public function process(ContainerBuilder $container) 31 { 32 $this->container = $container; 33 34 foreach ($container->getDefinitions() as $id => $definition) { 35 $this->sourceId = $id; 36 $this->processDefinition($definition); 37 } 38 } 39 40 private function processDefinition(Definition $definition) 41 { 42 $this->processReferences($definition->getArguments()); 43 $this->processReferences($definition->getMethodCalls()); 44 $this->processReferences($definition->getProperties()); 45 } 46 47 private function processReferences(array $arguments) 48 { 49 foreach ($arguments as $argument) { 50 if (is_array($argument)) { 51 $this->processReferences($argument); 52 } elseif ($argument instanceof Definition) { 53 $this->processDefinition($argument); 54 } elseif ($argument instanceof Reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $argument->getInvalidBehavior()) { 55 $destId = (string) $argument; 56 57 if (!$this->container->has($destId)) { 58 throw new ServiceNotFoundException($destId, $this->sourceId); 59 } 60 } 61 } 62 } 63 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |