You are here

class RouteEnhancerSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php \Drupal\Core\EventSubscriber\RouteEnhancerSubscriber

Listens to the new routes before they get saved.

Hierarchy

Expanded class hierarchy of RouteEnhancerSubscriber

1 string reference to 'RouteEnhancerSubscriber'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses RouteEnhancerSubscriber
route_enhancer_subscriber in core/core.services.yml
Drupal\Core\EventSubscriber\RouteEnhancerSubscriber

File

core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php, line 18
Contains \Drupal\Core\EventSubscriber\RouteEnhancerSubscriber.

Namespace

Drupal\Core\EventSubscriber
View source
class RouteEnhancerSubscriber implements EventSubscriberInterface {

  /**
   * @var \Drupal\Core\Routing\LazyRouteEnhancer
   */
  protected $routeEnhancer;

  /**
   * Constructs the RouteEnhancerSubscriber object.
   *
   * @param \Drupal\Core\Routing\LazyRouteEnhancer $route_enhancer
   *   The lazy route enhancer.
   */
  public function __construct(LazyRouteEnhancer $route_enhancer) {
    $this->routeEnhancer = $route_enhancer;
  }

  /**
   * Adds the route_enhancer object to the route collection.
   *
   * @param \Drupal\Core\Routing\RouteBuildEvent $event
   *   The route build event.
   */
  public function onRouteAlter(RouteBuildEvent $event) {
    $this->routeEnhancer
      ->setEnhancers($event
      ->getRouteCollection());
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[RoutingEvents::ALTER][] = array(
      'onRouteAlter',
      -300,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteEnhancerSubscriber::$routeEnhancer protected property
RouteEnhancerSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
RouteEnhancerSubscriber::onRouteAlter public function Adds the route_enhancer object to the route collection.
RouteEnhancerSubscriber::__construct public function Constructs the RouteEnhancerSubscriber object.