[ Index ]

PHP Cross Reference of phpBB-3.3.5-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Compiler/ -> AutoAliasServicePass.php (source)

   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\Alias;
  15  use Symfony\Component\DependencyInjection\ContainerBuilder;
  16  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  17  
  18  /**
  19   * Sets a service to be an alias of another one, given a format pattern.
  20   */
  21  class AutoAliasServicePass implements CompilerPassInterface
  22  {
  23      /**
  24       * {@inheritdoc}
  25       */
  26      public function process(ContainerBuilder $container)
  27      {
  28          foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
  29              foreach ($tags as $tag) {
  30                  if (!isset($tag['format'])) {
  31                      throw new InvalidArgumentException(sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
  32                  }
  33  
  34                  $aliasId = $container->getParameterBag()->resolveValue($tag['format']);
  35                  if ($container->hasDefinition($aliasId) || $container->hasAlias($aliasId)) {
  36                      $container->setAlias($serviceId, new Alias($aliasId, true));
  37                  }
  38              }
  39          }
  40      }
  41  }


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1