From 72c83bfc93182c0798bfdab4da73607ad9366b80 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 8 Dec 2020 15:27:34 +0100 Subject: [PATCH] fixed json cache bug on ajax home --- .../src/Controller/AjaxHomeController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/modules/custom/materio_home/src/Controller/AjaxHomeController.php b/web/modules/custom/materio_home/src/Controller/AjaxHomeController.php index 899b381..1051e2b 100644 --- a/web/modules/custom/materio_home/src/Controller/AjaxHomeController.php +++ b/web/modules/custom/materio_home/src/Controller/AjaxHomeController.php @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Symfony\Component\HttpFoundation\JsonResponse; use Drupal\Core\Cache\CacheableJsonResponse; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Url; @@ -94,11 +95,11 @@ class AjaxHomeController extends ControllerBase { 'languages:language_content' ] ]; - // $response = new JsonResponse(); - // $response->setData($data); - $response = new CacheableJsonResponse($data); - $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data)); - $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable)); + $response = new JsonResponse(); + $response->setData($data); + // $response = new CacheableJsonResponse($data); + // $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data)); + // $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable)); return $response; }