[ Index ] |
PHP Cross Reference of phpBB-3.3.14-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\ContainerBuilder; 15 use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; 16 use Symfony\Component\DependencyInjection\Reference; 17 18 /** 19 * Replaces all references to aliases with references to the actual service. 20 * 21 * @author Johannes M. Schmitt <schmittjoh@gmail.com> 22 */ 23 class ResolveReferencesToAliasesPass extends AbstractRecursivePass 24 { 25 /** 26 * {@inheritdoc} 27 */ 28 public function process(ContainerBuilder $container) 29 { 30 parent::process($container); 31 32 foreach ($container->getAliases() as $id => $alias) { 33 $aliasId = $container->normalizeId($alias); 34 if ($aliasId !== $defId = $this->getDefinitionId($aliasId, $container)) { 35 $container->setAlias($id, $defId)->setPublic($alias->isPublic())->setPrivate($alias->isPrivate()); 36 } 37 } 38 } 39 40 /** 41 * {@inheritdoc} 42 */ 43 protected function processValue($value, $isRoot = false) 44 { 45 if ($value instanceof Reference) { 46 $defId = $this->getDefinitionId($id = $this->container->normalizeId($value), $this->container); 47 48 if ($defId !== $id) { 49 return new Reference($defId, $value->getInvalidBehavior()); 50 } 51 } 52 53 return parent::processValue($value); 54 } 55 56 /** 57 * Resolves an alias into a definition id. 58 * 59 * @param string $id The definition or alias id to resolve 60 * 61 * @return string The definition id with aliases resolved 62 */ 63 private function getDefinitionId($id, ContainerBuilder $container) 64 { 65 $seen = []; 66 while ($container->hasAlias($id)) { 67 if (isset($seen[$id])) { 68 throw new ServiceCircularReferenceException($id, array_merge(array_keys($seen), [$id])); 69 } 70 $seen[$id] = true; 71 $id = $container->normalizeId($container->getAlias($id)); 72 } 73 74 return $id; 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |