function RegisterEventSubscribersPass::renameTag

Renames tags in the container.

Parameters

\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container.

string $source_tag: The tag to be renamed.

string $target_tag: The tag to rename with.

1 call to RegisterEventSubscribersPass::renameTag()
RegisterEventSubscribersPass::process in core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php

File

core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php, line 43

Class

RegisterEventSubscribersPass
Wraps the Symfony event subscriber pass to use different tag names.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

protected function renameTag(ContainerBuilder $container, string $source_tag, string $target_tag) : void {
  foreach ($container->getDefinitions() as $definition) {
    if ($definition->hasTag($source_tag)) {
      $attributes = $definition->getTag($source_tag)[0];
      $definition->addTag($target_tag, $attributes);
      $definition->clearTag($source_tag);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.