Loading resources/js/init.js +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ loading = true; var hash = sessionStorage.getItem("pt-tree-hash"); Drupal.restconsumer.get('/pagetree/tree/' + hash).done(function (data) { if (data.hash !== hash) { if (typeof data.hash != 'undefined' && data.hash !== hash) { sessionStorage.setItem("pt-tree-hash", data.hash); createTree(data, currentNode); } Loading @@ -38,6 +38,9 @@ } loading = true; Drupal.restconsumer.get('/pagetree/tree/-').done(function (data) { if (typeof data.hash == 'undefined') { data.hash = "-"; } sessionStorage.setItem("pt-tree-hash", data.hash); createTree(data, currentNode); loading = false; Loading src/Plugin/rest/resource/Tree.php +13 −7 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ class Tree extends ResourceBase { throw new AccessDeniedHttpException('You are not allowed to see the page tree.'); } $data = \Drupal::service('pagetree.tree')->get(); if (empty($data)) { $response = new ResourceResponse($data); $response->addCacheableDependency(['#cache' => ['max-age' => 0]]); } else { $cache = $data['#cache']; unset($data['#cache']); if ($data['hash'] == $hash) { Loading @@ -86,6 +91,7 @@ class Tree extends ResourceBase { $response = new ResourceResponse($data); } $response->addCacheableDependency($cache); } return $response; } Loading src/Service/Tree.php +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ class Tree { $this->_contentTypes = \Drupal::configFactory()->get('pagetree.settings')->get('contentTypes'); $languagesSelected = \Drupal::configFactory()->get('pagetree.settings')->get('languages'); $this->_languagesUsed = []; $translations = []; $languages = \Drupal::service('language_manager')->getLanguages(); $this->_languagesUsed = []; if ($languagesSelected != NULL && count($languagesSelected) > 0) { Loading Loading
resources/js/init.js +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ loading = true; var hash = sessionStorage.getItem("pt-tree-hash"); Drupal.restconsumer.get('/pagetree/tree/' + hash).done(function (data) { if (data.hash !== hash) { if (typeof data.hash != 'undefined' && data.hash !== hash) { sessionStorage.setItem("pt-tree-hash", data.hash); createTree(data, currentNode); } Loading @@ -38,6 +38,9 @@ } loading = true; Drupal.restconsumer.get('/pagetree/tree/-').done(function (data) { if (typeof data.hash == 'undefined') { data.hash = "-"; } sessionStorage.setItem("pt-tree-hash", data.hash); createTree(data, currentNode); loading = false; Loading
src/Plugin/rest/resource/Tree.php +13 −7 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ class Tree extends ResourceBase { throw new AccessDeniedHttpException('You are not allowed to see the page tree.'); } $data = \Drupal::service('pagetree.tree')->get(); if (empty($data)) { $response = new ResourceResponse($data); $response->addCacheableDependency(['#cache' => ['max-age' => 0]]); } else { $cache = $data['#cache']; unset($data['#cache']); if ($data['hash'] == $hash) { Loading @@ -86,6 +91,7 @@ class Tree extends ResourceBase { $response = new ResourceResponse($data); } $response->addCacheableDependency($cache); } return $response; } Loading
src/Service/Tree.php +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ class Tree { $this->_contentTypes = \Drupal::configFactory()->get('pagetree.settings')->get('contentTypes'); $languagesSelected = \Drupal::configFactory()->get('pagetree.settings')->get('languages'); $this->_languagesUsed = []; $translations = []; $languages = \Drupal::service('language_manager')->getLanguages(); $this->_languagesUsed = []; if ($languagesSelected != NULL && count($languagesSelected) > 0) { Loading