diff --git a/_dev/apps/ui/src/store/modules/app/actions-types.ts b/_dev/apps/ui/src/store/modules/app/actions-types.ts index 63f316a0dd..defe45f9fc 100644 --- a/_dev/apps/ui/src/store/modules/app/actions-types.ts +++ b/_dev/apps/ui/src/store/modules/app/actions-types.ts @@ -23,6 +23,7 @@ enum ActionsTypes { CHECK_FOR_AD_BLOCKER = 'CHECK_FOR_AD_BLOCKER', GET_API_HEALTHCHECK = 'GET_API_HEALTHCHECK', GET_MODULES_VERSIONS = 'GET_MODULES_VERSIONS', + TRIGGER_REGISTER_HOOK = 'TRIGGER_REGISTER_HOOK', } export {ActionsTypes as default}; diff --git a/_dev/apps/ui/src/store/modules/app/actions.ts b/_dev/apps/ui/src/store/modules/app/actions.ts index f0514d8154..704cef0ff8 100644 --- a/_dev/apps/ui/src/store/modules/app/actions.ts +++ b/_dev/apps/ui/src/store/modules/app/actions.ts @@ -96,4 +96,8 @@ export default { return error; } }, + // eslint-disable-next-line no-empty-pattern + async [ActionsTypes.TRIGGER_REGISTER_HOOK]({}, hookName: string) { + return fetchShop('registerHook', {hookName}); + }, }; diff --git a/_dev/apps/ui/src/views/debug.vue b/_dev/apps/ui/src/views/debug.vue index 237377b945..28434515e6 100644 --- a/_dev/apps/ui/src/views/debug.vue +++ b/_dev/apps/ui/src/views/debug.vue @@ -69,10 +69,19 @@ Hook list: @@ -263,13 +272,14 @@ - diff --git a/controllers/admin/AdminAjaxPsxMktgWithGoogleController.php b/controllers/admin/AdminAjaxPsxMktgWithGoogleController.php index d50d7150ae..559709a749 100644 --- a/controllers/admin/AdminAjaxPsxMktgWithGoogleController.php +++ b/controllers/admin/AdminAjaxPsxMktgWithGoogleController.php @@ -146,6 +146,9 @@ public function displayAjax() case 'getModuleStatus': $this->getModuleStatus($inputs); break; + case 'registerHook': + $this->registerHook($inputs); + break; default: http_response_code(400); $this->ajaxDie(json_encode(['success' => false, 'message' => $this->l('Action is missing or incorrect.')])); @@ -512,6 +515,23 @@ private function getUserDocumentation() return $baseUrl . '/user_guide_' . $isoCode . '.pdf'; } + private function registerHook(array $inputs) + { + if (!isset($inputs['hookName'])) { + http_response_code(400); + $this->ajaxDie(json_encode([ + 'success' => false, + 'message' => 'Missing hookName key', + ])); + } + + $this->ajaxDie( + json_encode([ + 'success' => $this->module->registerHook($inputs['hookName']), + ]) + ); + } + /** * Use cUrl to get HTTP headers and detect any HTTP 404 *