You are here

public function EarlyRenderingControllerWrapperSubscriber::onController in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Ensures bubbleable metadata from early rendering is not lost.

Parameters

\Symfony\Component\HttpKernel\Event\ControllerEvent $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(ControllerEvent $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);
  });
}