Browse Source

added language context to json cache to articles and collection

Bachir Soussi Chiadmi 5 years ago
parent
commit
80f02c3250

+ 13 - 7
sites/all/modules/figli/edlp_corpus/src/Controller/CorpusController.php

@@ -342,7 +342,10 @@ class CorpusController extends ControllerBase {
 
     $data['#cache'] = [
       'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
-      'tags' => ['edlp-articlesindex-cache']
+      'tags' => ['edlp-articlesindex-cache'],
+      'contexts' => [
+        'languages:language_content'
+      ]
     ];
 
     // $response = new JsonResponse();
@@ -356,14 +359,14 @@ class CorpusController extends ControllerBase {
 
 
 
-//   ___     _ _        _   _
-//  / __|___| | |___ __| |_(_)___ _ _
-// | (__/ _ \ | / -_) _|  _| / _ \ ' \
-//  \___\___/_|_\___\__|\__|_\___/_||_|
+  //   ___     _ _        _   _
+  //  / __|___| | |___ __| |_(_)___ _ _
+  // | (__/ _ \ | / -_) _|  _| / _ \ ' \
+  //  \___\___/_|_\___\__|\__|_\___/_||_|
 
   private function collectionQuery(){
     $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
-    
+
     $query = \Drupal::entityQuery('taxonomy_term')
       // ->sort('weight', 'DESC')
       // ->sort('name', 'DESC')
@@ -435,7 +438,10 @@ class CorpusController extends ControllerBase {
 
     $data['#cache'] = [
       'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
-      'tags' => ['edlp-articlesindex-cache']
+      'tags' => ['edlp-articlesindex-cache'],
+      'contexts' => [
+        'languages:language_content'
+      ]
     ];
 
     // $response = new JsonResponse();