class RegisterMatchersPass

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

Hierarchy

Expanded class hierarchy of RegisterMatchersPass

1 file declares its use of RegisterMatchersPass
CoreBundle.php in drupal/core/lib/Drupal/Core/CoreBundle.php
Definition of Drupal\Core\CoreBundle.

File

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

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class RegisterMatchersPass implements CompilerPassInterface {

  /**
   * Adds services tagged 'chained_matcher' to the 'matcher' service.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
   *  The container to process.
   */
  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,
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegisterMatchersPass::process public function Adds services tagged 'chained_matcher' to the 'matcher' service. Overrides CompilerPassInterface::process