You are here

public function MockedDynamicPageCacheSubscriber::onRouteMatch in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 modules/permissions_by_entity/tests/modules/pbt_entity_test/src/EventSubscriber/MockedDynamicPageCacheSubscriber.php \Drupal\pbt_entity_test\EventSubscriber\MockedDynamicPageCacheSubscriber::onRouteMatch()

File

modules/permissions_by_entity/tests/modules/pbt_entity_test/src/EventSubscriber/MockedDynamicPageCacheSubscriber.php, line 19

Class

MockedDynamicPageCacheSubscriber
Mocked dynamic page cache subscriber.

Namespace

Drupal\pbt_entity_test\EventSubscriber

Code

public function onRouteMatch(GetResponseEvent $event) {

  // Sets the response for the current route, if cached.
  $cached = $this->renderCache
    ->get($this->dynamicPageCacheRedirectRenderArray);
  if ($cached) {
    $response = $this
      ->renderArrayToResponse($cached);
    $response->headers
      ->set(self::HEADER, 'HIT');
    $event
      ->setResponse($response);
  }
}