Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AutoAliasServicePass.php

class AutoAliasServicePass

Sets a service to be an alias of another one, given a format pattern.

Hierarchy

  • class \Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of AutoAliasServicePass

File

vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php, line 21

Namespace

Symfony\Component\DependencyInjection\Compiler
View source
class AutoAliasServicePass implements CompilerPassInterface {
    public function process(ContainerBuilder $container) : void {
        foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
            foreach ($tags as $tag) {
                if (!isset($tag['format'])) {
                    throw new InvalidArgumentException(\sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
                }
                $aliasId = $container->getParameterBag()
                    ->resolveValue($tag['format']);
                if ($container->hasDefinition($aliasId) || $container->hasAlias($aliasId)) {
                    $alias = new Alias($aliasId, $container->getDefinition($serviceId)
                        ->isPublic());
                    $container->setAlias($serviceId, $alias);
                }
            }
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AutoAliasServicePass::process public function You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface::process

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal