You are here

class RouterRebuildSubscriber in Zircon Profile 8

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

Rebuilds the router if needed at the end of the request.

Hierarchy

Expanded class hierarchy of RouterRebuildSubscriber

File

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

Namespace

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

  /**
   * @var \Drupal\Core\Routing\RouteBuilderInterface
   */
  protected $routeBuilder;

  /**
   * Constructs the RouterRebuildSubscriber object.
   *
   * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
   *   The route builder.
   */
  public function __construct(RouteBuilderInterface $route_builder) {
    $this->routeBuilder = $route_builder;
  }

  /**
   * Rebuilds routers if necessary.
   *
   * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
   *   The event object.
   */
  public function onKernelTerminate(PostResponseEvent $event) {
    $this->routeBuilder
      ->rebuildIfNeeded();
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::TERMINATE][] = array(
      'onKernelTerminate',
      200,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouterRebuildSubscriber::$routeBuilder protected property
RouterRebuildSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
RouterRebuildSubscriber::onKernelTerminate public function Rebuilds routers if necessary.
RouterRebuildSubscriber::__construct public function Constructs the RouterRebuildSubscriber object.