function EarlyRenderingControllerWrapperSubscriber::onController

Same name in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php \Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController()
  2. 10 core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php \Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController()
  3. 11.x core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php \Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController()

Ensures bubbleable metadata from early rendering is not lost.

Parameters

\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event: The controller event.

File

core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php, line 90

Class

EarlyRenderingControllerWrapperSubscriber
Subscriber that wraps controllers, to handle early rendering.

Namespace

Drupal\Core\EventSubscriber

Code

public function onController(FilterControllerEvent $event) {
    $controller = $event->getController();
    // See \Symfony\Component\HttpKernel\HttpKernel::handleRaw().
    $arguments = $this->argumentResolver
        ->getArguments($event->getRequest(), $controller);
    $event->setController(function () use ($controller, $arguments) {
        return $this->wrapControllerExecutionInRenderContext($controller, $arguments);
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.