public function RegisterMatchersPass::process

Adds services tagged 'chained_matcher' to the 'matcher' service.

Parameters

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

Overrides CompilerPassInterface::process

File

drupal/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterMatchersPass.php, line 25
Contains Drupal\Core\DependencyInjection\Compiler\RegisterMatchersPass.

Class

RegisterMatchersPass
Adds services tagged 'chained_matcher' to the 'matcher' service.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  if (!$container
    ->hasDefinition('matcher')) {
    return;
  }
  $matcher = $container
    ->getDefinition('matcher');
  foreach ($container
    ->findTaggedServiceIds('chained_matcher') as $id => $attributes) {
    $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
    $matcher
      ->addMethodCall('add', array(
      new Reference($id),
      $priority,
    ));
  }
}