public function MockedDynamicPageCacheSubscriber::onResponse in Permissions by Term 8
Same name and namespace in other branches
- 8.2 modules/permissions_by_entity/tests/modules/pbt_entity_test/src/EventSubscriber/MockedDynamicPageCacheSubscriber.php \Drupal\pbt_entity_test\EventSubscriber\MockedDynamicPageCacheSubscriber::onResponse()
Stores a response in case of a Dynamic Page Cache miss, if cacheable.
Parameters
\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.
Overrides DynamicPageCacheSubscriber::onResponse
File
- modules/
permissions_by_entity/ tests/ modules/ pbt_entity_test/ src/ EventSubscriber/ MockedDynamicPageCacheSubscriber.php, line 32
Class
- MockedDynamicPageCacheSubscriber
- Mocked dynamic page cache subscriber.
Namespace
Drupal\pbt_entity_test\EventSubscriberCode
public function onResponse(FilterResponseEvent $event) {
$response = $event
->getResponse();
// Embed the response object in a render array so that RenderCache is able
// to cache it, handling cache redirection for us.
$response_as_render_array = $this
->responseToRenderArray($response);
$this->renderCache
->set($response_as_render_array, $this->dynamicPageCacheRedirectRenderArray);
// The response was generated, mark the response as a cache miss. The next
// time, it will be a cache hit.
$response->headers
->set(self::HEADER, 'MISS');
}