Skip to content
Snippets Groups Projects
Commit c66dbcca authored by Volker Killesreiter's avatar Volker Killesreiter Committed by Markus Kalkbrenner
Browse files

Issue #3278243: Add return type declarations

parent 1f1b61de
No related branches found
No related tags found
1 merge request!1Issue #3278243: Add return type declarations
<?php
/**
* @file
* Contains \Drupal\prefetch_cache\StackMiddleware\PrefetchCacheAfterSessionInitialized.
*/
namespace Drupal\prefetch_cache\StackMiddleware;
use Drupal\page_cache\StackMiddleware\PageCache;
......@@ -17,11 +12,13 @@ use Drupal\prefetch_cache\PrefetchCacheInterface;
* Executes the prefetch caching before the main kernel takes over the request.
*
* Runs after PrefetchCacheBeforePageCache, PageCache and Session.
*
*/
class PrefetchCacheAfterSessionInitialized extends PageCache {
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
$response = NULL;
$is_cache_request = $request->attributes->has(PrefetchCacheInterface::PREFETCH_CACHE_REQUEST);
$has_token_id = $request->attributes->has(PrefetchCacheInterface::PREFETCH_CACHE_TOKEN_ID);
......@@ -67,7 +64,7 @@ class PrefetchCacheAfterSessionInitialized extends PageCache {
/**
* {@inheritdoc}
*/
protected function getCacheId(Request $request) {
protected function getCacheId(Request $request) {
$cache_id = $request->attributes->get(PrefetchCacheInterface::PREFETCH_CACHE_CACHE_ID);
if (!$cache_id) {
......
......@@ -12,6 +12,7 @@ use Drupal\Component\Serialization\Json;
use Drupal\page_cache\StackMiddleware\PageCache;
use Drupal\Core\Cache\CacheBackendInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Drupal\prefetch_cache\PrefetchCacheInterface;
use Drupal\prefetch_cache\Cache\ChainCacheTagsGeneratorInterface;
......@@ -61,7 +62,7 @@ class PrefetchCacheBeforePageCache extends PageCache {
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE): Response {
$response = NULL;
$is_cache_request = $request->query->has(PrefetchCacheInterface::PREFETCH_CACHE_REQUEST);
$has_token_id = $request->query->has(PrefetchCacheInterface::PREFETCH_CACHE_TOKEN_ID);
......@@ -79,7 +80,6 @@ class PrefetchCacheBeforePageCache extends PageCache {
$response = $this->httpKernel->handle($request, $type, $catch);
// The response has been cached by page cache.
if ($response->headers->contains('X-Drupal-Cache', 'HIT') || $response->headers->contains('X-Drupal-Cache', 'MISS')) {
$response->setContent(Json::encode(['cached_by_page_cache' => TRUE]));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment