class RegisterRouteEnhancersPass

Registers route enhancer services with the router.

Hierarchy

Expanded class hierarchy of RegisterRouteEnhancersPass

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

File

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

Namespace

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

  /**
   * Adds services tagged with "route_enhancer" to the router.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
   *   The container to process.
   */
  public function process(ContainerBuilder $container) {
    if (!$container
      ->hasDefinition('router.dynamic')) {
      return;
    }
    $router = $container
      ->getDefinition('router.dynamic');
    foreach ($container
      ->findTaggedServiceIds('route_enhancer') as $id => $attributes) {
      $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
      $router
        ->addMethodCall('addRouteEnhancer', array(
        new Reference($id),
        $priority,
      ));
    }
    $legacy_router = $container
      ->getDefinition('legacy_router');
    foreach ($container
      ->findTaggedServiceIds('legacy_route_enhancer') as $id => $attributes) {
      $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
      $legacy_router
        ->addMethodCall('addRouteEnhancer', array(
        new Reference($id),
        $priority,
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegisterRouteEnhancersPass::process public function Adds services tagged with "route_enhancer" to the router. Overrides CompilerPassInterface::process