From 2ff09416db71375b69c6480cfdaa1aa89284ea73 Mon Sep 17 00:00:00 2001 From: Muhammad Shahrukh <> Date: Wed, 4 Sep 2024 13:34:21 +0500 Subject: [PATCH] COMCL-707: Fix case type category terms --- CRM/Civicase/Event/Listener/AssetBuilder.php | 2 +- CRM/Civicase/Hook/Helper/CaseTypeCategory.php | 2 +- .../PageRun/AddCaseTypeCategoryToCache.php | 33 ------------------- CRM/Civicase/Settings.php | 3 +- civicase.php | 1 - 5 files changed, 4 insertions(+), 37 deletions(-) delete mode 100644 CRM/Civicase/Hook/PageRun/AddCaseTypeCategoryToCache.php diff --git a/CRM/Civicase/Event/Listener/AssetBuilder.php b/CRM/Civicase/Event/Listener/AssetBuilder.php index d9c2a9752..9b55729f5 100644 --- a/CRM/Civicase/Event/Listener/AssetBuilder.php +++ b/CRM/Civicase/Event/Listener/AssetBuilder.php @@ -16,7 +16,7 @@ class CRM_Civicase_Event_Listener_AssetBuilder { */ public static function addWordReplacements(GenericHookEvent $event) { if ($event->asset == 'angular-modules.json') { - $caseCategoryName = \Civi::cache('metadata')->get('current_case_category'); + $caseCategoryName = CRM_Core_Session::singleton()->get('current_case_category'); CRM_Civicase_Hook_Helper_CaseTypeCategory::addWordReplacements($caseCategoryName); // Rebuild the asset if it has been built. diff --git a/CRM/Civicase/Hook/Helper/CaseTypeCategory.php b/CRM/Civicase/Hook/Helper/CaseTypeCategory.php index cc6d48d2f..ef1a24fc9 100644 --- a/CRM/Civicase/Hook/Helper/CaseTypeCategory.php +++ b/CRM/Civicase/Hook/Helper/CaseTypeCategory.php @@ -69,7 +69,7 @@ public static function addWordReplacements($caseCategoryName) { } CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode(); - \Civi::cache('metadata')->set('current_case_category', $caseCategoryName); + CRM_Core_Session::singleton()->set('current_case_category', $caseCategoryName); $wordReplacements = CaseCategoryHelper::getWordReplacements($caseCategoryName); if (empty($wordReplacements)) { return; diff --git a/CRM/Civicase/Hook/PageRun/AddCaseTypeCategoryToCache.php b/CRM/Civicase/Hook/PageRun/AddCaseTypeCategoryToCache.php deleted file mode 100644 index c70c1d8e2..000000000 --- a/CRM/Civicase/Hook/PageRun/AddCaseTypeCategoryToCache.php +++ /dev/null @@ -1,33 +0,0 @@ -addCaseTypeCategoryToCache(); - } - - /** - * Add case type category to cache. - */ - private function addCaseTypeCategoryToCache(): void { - if (CRM_Utils_System::currentPath() === 'civicrm/case/a') { - $caseCategoryInfo = CaseUrlHelper::getCategoryParamsFromUrl(); - \Civi::cache('metadata')->set('current_case_category', $caseCategoryInfo[1]); - } - elseif (!in_array(CRM_Utils_System::currentPath(), ['civicrm/asset/builder', 'civicrm/user-menu'], TRUE)) { - \Civi::cache('metadata')->set('current_case_category', NULL); - } - } - -} diff --git a/CRM/Civicase/Settings.php b/CRM/Civicase/Settings.php index 995e92a9e..b6870bb6c 100644 --- a/CRM/Civicase/Settings.php +++ b/CRM/Civicase/Settings.php @@ -1,12 +1,12 @@ get($caseCategoryName); $caseCategorySetting = new CRM_Civicase_Service_CaseCategorySetting(); diff --git a/civicase.php b/civicase.php index 0dbcd34f6..b2e8c81cb 100644 --- a/civicase.php +++ b/civicase.php @@ -415,7 +415,6 @@ function civicase_civicrm_pageRun(&$page) { new CRM_Civicase_Hook_PageRun_AddCaseAngularPageResources(), new CRM_Civicase_Hook_PageRun_AddContactPageSummaryResources(), new CRM_Civicase_Hook_PageRun_CaseCategoryCustomGroupListing(), - new CRM_Civicase_Hook_PageRun_AddCaseTypeCategoryToCache(), ]; foreach ($hooks as $hook) {