From 0e60dbba544fa7a7bd04dde9df4c0b06737219ec Mon Sep 17 00:00:00 2001 From: Vincent Garcia Date: Mon, 21 Oct 2024 16:57:41 +0200 Subject: [PATCH 1/4] :construction: Try to remove hook. In order to improve perf, trying to remove dispatcherBefore hook usage. MBO module is quite heavy, and do not need to be loaded on every request. --- ps_mbo.php | 4 +- .../Hooks/UseActionDispatcherBefore.php | 228 ------------------ .../Hooks/UseDisplayAdminAfterHeader.php | 192 +++++++++++++++ src/Traits/UseHooks.php | 1 - upgrade/upgrade-4.12.1.php | 39 +++ 5 files changed, 233 insertions(+), 231 deletions(-) delete mode 100644 src/Traits/Hooks/UseActionDispatcherBefore.php create mode 100644 upgrade/upgrade-4.12.1.php diff --git a/ps_mbo.php b/ps_mbo.php index ae50e9485..bcc5e1a28 100755 --- a/ps_mbo.php +++ b/ps_mbo.php @@ -33,11 +33,11 @@ use PrestaShop\Module\Mbo\Addons\Subscriber\ModuleManagementEventSubscriber; use PrestaShop\Module\Mbo\Api\Security\AdminAuthenticationProvider; use PrestaShop\Module\Mbo\Helpers\Config; +use PrestaShop\Module\Mbo\Helpers\ErrorHelper; use PrestaShop\PrestaShop\Adapter\SymfonyContainer; use PrestaShopBundle\Event\ModuleManagementEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Dotenv\Dotenv; -use PrestaShop\Module\Mbo\Helpers\ErrorHelper; class ps_mbo extends Module { @@ -94,7 +94,7 @@ class ps_mbo extends Module public function __construct() { $this->name = 'ps_mbo'; - $this->version = '4.12.0'; + $this->version = '4.12.1'; $this->author = 'PrestaShop'; $this->tab = 'administration'; $this->module_key = '6cad5414354fbef755c7df4ef1ab74eb'; diff --git a/src/Traits/Hooks/UseActionDispatcherBefore.php b/src/Traits/Hooks/UseActionDispatcherBefore.php deleted file mode 100644 index 1842b618e..000000000 --- a/src/Traits/Hooks/UseActionDispatcherBefore.php +++ /dev/null @@ -1,228 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -declare(strict_types=1); - -namespace PrestaShop\Module\Mbo\Traits\Hooks; - -use Cache; -use Configuration; -use Context; -use Dispatcher; -use Exception; -use Language; -use PrestaShop\Module\Mbo\Distribution\Config\Command\VersionChangeApplyConfigCommand; -use PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\VersionChangeApplyConfigCommandHandler; -use PrestaShop\Module\Mbo\Helpers\Config; -use PrestaShop\Module\Mbo\Helpers\ErrorHelper; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use Shop; -use Tab; -use Tools; - -trait UseActionDispatcherBefore -{ - /** - * Hook actionDispatcherBefore. - * - * @throws EmployeeException - * @throws CoreException - */ - public function hookActionDispatcherBefore(array $params): void - { - $controllerName = Tools::getValue('controller'); - - $this->translateTabsIfNeeded(); - - // Registration failed on install, retry it - if (in_array($controllerName, [ - 'AdminPsMboModuleParent', - 'AdminPsMboRecommended', - 'apiPsMbo', - ])) { - $this->ensureShopIsRegistered(); - $this->ensureShopIsUpdated(); - $this->ensureApiConfigIsApplied(); - } - - if (self::checkModuleStatus()) { // If the module is not active, config values are not set yet - $this->ensureApiUserExistAndIsLogged($controllerName, $params); - } - } - - private function ensureShopIsRegistered(): void - { - if (!file_exists($this->moduleCacheDir . 'registerShop.lock') && $this->ensureShopIsConfigured()) { - return; - } - $this->registerShop(); - } - - private function ensureShopIsConfigured(): bool - { - $configurationList = []; - $configurationList['PS_MBO_SHOP_ADMIN_UUID'] = false; - $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] = false; - $configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] = false; - - foreach ($configurationList as $name => $value) { - if (Configuration::hasKey($name)) { - $configurationList[$name] = true; - } - } - - if ($configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] - && $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] - && $configurationList['PS_MBO_SHOP_ADMIN_UUID']) { - return true; - } - - foreach (Shop::getShops(false, null, true) as $shopId) { - foreach ($configurationList as $name => $value) { - if (Configuration::hasKey($name, null, null, (int) $shopId)) { - $configurationList[$name] = true; - } - } - } - - return $configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] - && $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] - && $configurationList['PS_MBO_SHOP_ADMIN_UUID']; - } - - private function ensureShopIsUpdated(): void - { - if (!file_exists($this->moduleCacheDir . 'updateShop.lock')) { - return; - } - $this->updateShop(); - } - - private function ensureApiConfigIsApplied(): void - { - try { - /** @var DoctrineProvider $cacheProvider */ - $cacheProvider = $this->get('doctrine.cache.provider'); - } catch (Exception $e) { - ErrorHelper::reportError($e); - $cacheProvider = false; - } - $cacheKey = 'mbo_last_ps_version_api_config_check'; - - if ($cacheProvider && $cacheProvider->contains($cacheKey)) { - $lastCheck = $cacheProvider->fetch($cacheKey); - - $timeSinceLastCheck = (strtotime('now') - strtotime($lastCheck)) / (60 * 60); - if ($timeSinceLastCheck < 3) { // If last check happened lss than 3hrs, do nothing - return; - } - } - - if (_PS_VERSION_ === Config::getLastPsVersionApiConfig()) { - // Config already applied for this version of PS - return; - } - - // Apply the config for the new PS version - $command = new VersionChangeApplyConfigCommand(_PS_VERSION_, $this->version); - try { - /** @var VersionChangeApplyConfigCommandHandler $configApplyHandler */ - $configApplyHandler = $this->get('mbo.distribution.api_version_change_config_apply_handler'); - } catch (Exception $e) { - ErrorHelper::reportError($e); - - return; - } - $configApplyHandler->handle($command); - - // Update the PS_MBO_LAST_PS_VERSION_API_CONFIG - Configuration::updateValue('PS_MBO_LAST_PS_VERSION_API_CONFIG', _PS_VERSION_); - - if ($cacheProvider) { - $cacheProvider->save($cacheKey, (new \DateTime())->format('Y-m-d H:i:s'), 0); - } - } - - /** - * @param string|bool $controllerName - * @param array $params - * - * @return void - * - * @throws EmployeeException - * @throws CoreException - * @throws Exception - */ - private function ensureApiUserExistAndIsLogged($controllerName, array $params): void - { - $apiUser = null; - // Whatever the call in the MBO API, we check if the MBO API user exists - if (Dispatcher::FC_ADMIN == (int) $params['controller_type'] || $controllerName === 'apiPsMbo') { - $apiUser = $this->getAdminAuthenticationProvider()->ensureApiUserExistence(); - } - - if ($controllerName !== 'apiPsMbo' || !$apiUser) { - return; - } - - if (!$apiUser->isLoggedBack()) { // Log the user - $cookie = $this->getAdminAuthenticationProvider()->apiUserLogin($apiUser); - - Cache::clean('isLoggedBack' . $apiUser->id); - - $this->context->employee = $apiUser; - $this->context->cookie = $cookie; - Context::getContext()->cookie = $cookie; - } - } - - private function translateTabsIfNeeded(): void - { - $lockFile = $this->moduleCacheDir . 'translate_tabs.lock'; - if (!file_exists($lockFile)) { - return; - } - - $moduleTabs = Tab::getCollectionFromModule($this->name); - $languages = Language::getLanguages(false); - - /** - * @var Tab $tab - */ - foreach ($moduleTabs as $tab) { - if (!empty($tab->wording) && !empty($tab->wording_domain)) { - $tabNameByLangId = []; - foreach ($languages as $language) { - $tabNameByLangId[$language['id_lang']] = $this->trans( - $tab->wording, - [], - $tab->wording_domain, - $language['locale'] - ); - } - - $tab->name = $tabNameByLangId; - $tab->save(); - } - } - - @unlink($lockFile); - } -} diff --git a/src/Traits/Hooks/UseDisplayAdminAfterHeader.php b/src/Traits/Hooks/UseDisplayAdminAfterHeader.php index bca2dd559..31cc12cad 100644 --- a/src/Traits/Hooks/UseDisplayAdminAfterHeader.php +++ b/src/Traits/Hooks/UseDisplayAdminAfterHeader.php @@ -22,11 +22,17 @@ namespace PrestaShop\Module\Mbo\Traits\Hooks; use Exception; +use PrestaShop\Module\Mbo\Distribution\Config\Command\VersionChangeApplyConfigCommand; +use PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\VersionChangeApplyConfigCommandHandler; use PrestaShop\Module\Mbo\Exception\ExpectedServiceNotFoundException; +use PrestaShop\Module\Mbo\Helpers\Config; use PrestaShop\Module\Mbo\Helpers\ErrorHelper; use PrestaShop\Module\Mbo\Service\View\ContextBuilder; +use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; +use PrestaShop\PrestaShop\Core\Exception\CoreException; use Tools; use Twig\Environment; +use Configuration; trait UseDisplayAdminAfterHeader { @@ -38,6 +44,8 @@ trait UseDisplayAdminAfterHeader */ public function hookDisplayAdminAfterHeader(): string { + $this->ensureModuleIsCorrectlySetUp(); + $shouldDisplayMboUserExplanation = $this->shouldDisplayMboUserExplanation(); $shouldDisplayModuleManagerMessage = $this->shouldDisplayModuleManagerMessage(); @@ -192,4 +200,188 @@ private function shouldDisplayModuleManagerMessage(): bool 'admin_module_updates', ]); } + + public function ensureModuleIsCorrectlySetUp(): void + { + $whitelistedControllers = [ + 'AdminPsMboModuleParent', + 'AdminPsMboRecommended', + 'apiPsMbo', + 'apiSecurityPsMbo', + 'AdminModulesManage', + ]; + $controllerName = Tools::getValue('controller'); + + if (!in_array($controllerName, $whitelistedControllers)) { + return; + } + + $this->translateTabsIfNeeded(); + $this->ensureShopIsRegistered(); + $this->ensureShopIsUpdated(); + $this->ensureApiConfigIsApplied(); + + if (self::checkModuleStatus()) { // If the module is not active, config values are not set yet + $this->ensureApiUserExistAndIsLogged($controllerName); + } + } + + private function ensureShopIsRegistered(): void + { + if (!file_exists($this->moduleCacheDir . 'registerShop.lock') && $this->ensureShopIsConfigured()) { + return; + } + $this->registerShop(); + } + + private function ensureShopIsConfigured(): bool + { + $configurationList = []; + $configurationList['PS_MBO_SHOP_ADMIN_UUID'] = false; + $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] = false; + $configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] = false; + + foreach ($configurationList as $name => $value) { + if (Configuration::hasKey($name)) { + $configurationList[$name] = true; + } + } + + if ($configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] + && $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] + && $configurationList['PS_MBO_SHOP_ADMIN_UUID']) { + return true; + } + + foreach (Shop::getShops(false, null, true) as $shopId) { + foreach ($configurationList as $name => $value) { + if (Configuration::hasKey($name, null, null, (int)$shopId)) { + $configurationList[$name] = true; + } + } + } + + return $configurationList['PS_MBO_LAST_PS_VERSION_API_CONFIG'] + && $configurationList['PS_MBO_SHOP_ADMIN_MAIL'] + && $configurationList['PS_MBO_SHOP_ADMIN_UUID']; + } + + private function ensureShopIsUpdated(): void + { + if (!file_exists($this->moduleCacheDir . 'updateShop.lock')) { + return; + } + $this->updateShop(); + } + + private function ensureApiConfigIsApplied(): void + { + try { + /** @var DoctrineProvider $cacheProvider */ + $cacheProvider = $this->get('doctrine.cache.provider'); + } catch (Exception $e) { + ErrorHelper::reportError($e); + $cacheProvider = false; + } + $cacheKey = 'mbo_last_ps_version_api_config_check'; + + if ($cacheProvider && $cacheProvider->contains($cacheKey)) { + $lastCheck = $cacheProvider->fetch($cacheKey); + + $timeSinceLastCheck = (strtotime('now') - strtotime($lastCheck)) / (60 * 60); + if ($timeSinceLastCheck < 3) { // If last check happened lss than 3hrs, do nothing + return; + } + } + + if (_PS_VERSION_ === Config::getLastPsVersionApiConfig()) { + // Config already applied for this version of PS + return; + } + + // Apply the config for the new PS version + $command = new VersionChangeApplyConfigCommand(_PS_VERSION_, $this->version); + try { + /** @var VersionChangeApplyConfigCommandHandler $configApplyHandler */ + $configApplyHandler = $this->get('mbo.distribution.api_version_change_config_apply_handler'); + } catch (Exception $e) { + ErrorHelper::reportError($e); + + return; + } + $configApplyHandler->handle($command); + + // Update the PS_MBO_LAST_PS_VERSION_API_CONFIG + Configuration::updateValue('PS_MBO_LAST_PS_VERSION_API_CONFIG', _PS_VERSION_); + + if ($cacheProvider) { + $cacheProvider->save($cacheKey, (new \DateTime())->format('Y-m-d H:i:s'), 0); + } + } + + /** + * @param string|bool $controllerName + * @param array $params + * + * @return void + * + * @throws EmployeeException + * @throws CoreException + * @throws Exception + */ + private function ensureApiUserExistAndIsLogged($controllerName): void + { + if ($controllerName !== 'apiPsMbo') { + return; + } + $apiUser = null; + $apiUser = $this->getAdminAuthenticationProvider()->ensureApiUserExistence(); + + if (!$apiUser) { + return; + } + + if (!$apiUser->isLoggedBack()) { // Log the user + $cookie = $this->getAdminAuthenticationProvider()->apiUserLogin($apiUser); + + Cache::clean('isLoggedBack' . $apiUser->id); + + $this->context->employee = $apiUser; + $this->context->cookie = $cookie; + Context::getContext()->cookie = $cookie; + } + } + + private function translateTabsIfNeeded(): void + { + $lockFile = $this->moduleCacheDir . 'translate_tabs.lock'; + if (!file_exists($lockFile)) { + return; + } + + $moduleTabs = Tab::getCollectionFromModule($this->name); + $languages = Language::getLanguages(false); + + /** + * @var Tab $tab + */ + foreach ($moduleTabs as $tab) { + if (!empty($tab->wording) && !empty($tab->wording_domain)) { + $tabNameByLangId = []; + foreach ($languages as $language) { + $tabNameByLangId[$language['id_lang']] = $this->trans( + $tab->wording, + [], + $tab->wording_domain, + $language['locale'] + ); + } + + $tab->name = $tabNameByLangId; + $tab->save(); + } + } + + @unlink($lockFile); + } } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 479e2552f..ae3253f93 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -48,7 +48,6 @@ trait UseHooks use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionListModules; use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionModuleRegisterHookAfter; use \PrestaShop\Module\Mbo\Traits\Hooks\UseDisplayEmptyModuleCategoryExtraMessage; - use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionDispatcherBefore; use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionObjectShopUrlUpdateAfter; use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionGeneralPageSave; use \PrestaShop\Module\Mbo\Traits\Hooks\UseActionBeforeUpgradeModule; diff --git a/upgrade/upgrade-4.12.1.php b/upgrade/upgrade-4.12.1.php new file mode 100644 index 000000000..8c8ad371e --- /dev/null +++ b/upgrade/upgrade-4.12.1.php @@ -0,0 +1,39 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +$rootDir = defined('_PS_ROOT_DIR_') ? _PS_ROOT_DIR_ : getenv('_PS_ROOT_DIR_'); +if (!$rootDir) { + $rootDir = __DIR__ . '/../../../'; +} + +require_once $rootDir . '/vendor/autoload.php'; + +/** + * @param ps_mbo $module + * + * @return bool + */ +function upgrade_module_4_12_1(Module $module): bool +{ + $module->updateHooks(); + $module->updateTabs(); + + return true; +} From 74e55af3fb96be59bf1fdef0acbd24155b31c55e Mon Sep 17 00:00:00 2001 From: Vincent Garcia Date: Mon, 21 Oct 2024 17:16:23 +0200 Subject: [PATCH 2/4] :bookmark: Update to 4.13.0 --- config.xml | 2 +- ps_mbo.php | 4 ++-- upgrade/{upgrade-4.12.1.php => upgrade-4.13.0.php} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename upgrade/{upgrade-4.12.1.php => upgrade-4.13.0.php} (95%) diff --git a/config.xml b/config.xml index debb9868f..1179cc69c 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_mbo - + diff --git a/ps_mbo.php b/ps_mbo.php index bcc5e1a28..ec80cb924 100755 --- a/ps_mbo.php +++ b/ps_mbo.php @@ -49,7 +49,7 @@ class ps_mbo extends Module /** * @var string */ - public const VERSION = '4.12.0'; + public const VERSION = '4.13.0'; public const CONTROLLERS_WITH_CONNECTION_TOOLBAR = [ 'AdminModulesManage', @@ -94,7 +94,7 @@ class ps_mbo extends Module public function __construct() { $this->name = 'ps_mbo'; - $this->version = '4.12.1'; + $this->version = '4.13.0'; $this->author = 'PrestaShop'; $this->tab = 'administration'; $this->module_key = '6cad5414354fbef755c7df4ef1ab74eb'; diff --git a/upgrade/upgrade-4.12.1.php b/upgrade/upgrade-4.13.0.php similarity index 95% rename from upgrade/upgrade-4.12.1.php rename to upgrade/upgrade-4.13.0.php index 8c8ad371e..c091a5d67 100644 --- a/upgrade/upgrade-4.12.1.php +++ b/upgrade/upgrade-4.13.0.php @@ -30,7 +30,7 @@ * * @return bool */ -function upgrade_module_4_12_1(Module $module): bool +function upgrade_module_4_13_0(Module $module): bool { $module->updateHooks(); $module->updateTabs(); From 394c21916bd3f955fd14d8abd5ea9bfbb992476a Mon Sep 17 00:00:00 2001 From: Vincent Garcia Date: Mon, 21 Oct 2024 17:33:26 +0200 Subject: [PATCH 3/4] :bug: Add missing import --- .../Hooks/UseDisplayAdminAfterHeader.php | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Traits/Hooks/UseDisplayAdminAfterHeader.php b/src/Traits/Hooks/UseDisplayAdminAfterHeader.php index 31cc12cad..1a5ecaa65 100644 --- a/src/Traits/Hooks/UseDisplayAdminAfterHeader.php +++ b/src/Traits/Hooks/UseDisplayAdminAfterHeader.php @@ -21,7 +21,11 @@ namespace PrestaShop\Module\Mbo\Traits\Hooks; +use Cache; +use Configuration; +use Context; use Exception; +use Language; use PrestaShop\Module\Mbo\Distribution\Config\Command\VersionChangeApplyConfigCommand; use PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\VersionChangeApplyConfigCommandHandler; use PrestaShop\Module\Mbo\Exception\ExpectedServiceNotFoundException; @@ -30,9 +34,10 @@ use PrestaShop\Module\Mbo\Service\View\ContextBuilder; use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; use PrestaShop\PrestaShop\Core\Exception\CoreException; +use Shop; +use Tab; use Tools; use Twig\Environment; -use Configuration; trait UseDisplayAdminAfterHeader { @@ -113,6 +118,7 @@ private function renderMboUserExplanation(): string ); } catch (Exception $e) { ErrorHelper::reportError($e); + return ''; } } @@ -144,13 +150,14 @@ private function renderModuleManagerMessage(): string ); } catch (Exception $e) { ErrorHelper::reportError($e); + return ''; } } private function shouldDisplayMboUserExplanation(): bool { - if (Tools::getValue('controller') !== "AdminEmployees") { + if (Tools::getValue('controller') !== 'AdminEmployees') { return false; } @@ -161,6 +168,7 @@ private function shouldDisplayMboUserExplanation(): bool } } catch (Exception $e) { ErrorHelper::reportError($e); + return false; } @@ -174,9 +182,9 @@ private function shouldDisplayModuleManagerMessage(): bool !in_array( Tools::getValue('controller'), [ - "AdminModulesManage", - "AdminModulesNotifications", - "AdminModulesUpdates", + 'AdminModulesManage', + 'AdminModulesNotifications', + 'AdminModulesUpdates', ] ) ) { @@ -190,6 +198,7 @@ private function shouldDisplayModuleManagerMessage(): bool } } catch (Exception $e) { ErrorHelper::reportError($e); + return false; } @@ -204,6 +213,7 @@ private function shouldDisplayModuleManagerMessage(): bool public function ensureModuleIsCorrectlySetUp(): void { $whitelistedControllers = [ + 'AdminPsMboModule', 'AdminPsMboModuleParent', 'AdminPsMboRecommended', 'apiPsMbo', @@ -255,7 +265,7 @@ private function ensureShopIsConfigured(): bool foreach (Shop::getShops(false, null, true) as $shopId) { foreach ($configurationList as $name => $value) { - if (Configuration::hasKey($name, null, null, (int)$shopId)) { + if (Configuration::hasKey($name, null, null, (int) $shopId)) { $configurationList[$name] = true; } } From 52c741f0eb26b09c48c6470471be95a06f91dc53 Mon Sep 17 00:00:00 2001 From: Vincent Garcia Date: Tue, 22 Oct 2024 11:04:46 +0200 Subject: [PATCH 4/4] :zap: Simplify the display of the catalog page. Stylesheet blocks seems to reload/build again the layout.tpl, and call twice hooks... --- .../Admin/ModuleCatalogController.php | 17 +---------------- .../Hooks/UseActionAdminControllerSetMedia.php | 3 ++- .../module_catalog/catalog.html.twig | 12 ------------ 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/Controller/Admin/ModuleCatalogController.php b/src/Controller/Admin/ModuleCatalogController.php index 8f0e23b58..040f941f7 100755 --- a/src/Controller/Admin/ModuleCatalogController.php +++ b/src/Controller/Admin/ModuleCatalogController.php @@ -46,21 +46,6 @@ class ModuleCatalogController extends ModuleAbstractController */ public function indexAction(): Response { - $moduleUri = __PS_BASE_URI__ . 'modules/ps_mbo/'; - - $extraParams = [ - 'cdc_error_templating_url' => $moduleUri . 'views/js/cdc-error-templating.js', - 'cdc_error_templating_css' => $moduleUri . 'views/css/cdc-error-templating.css', - ]; - - $cdcJsFile = getenv('MBO_CDC_URL'); - if (false === $cdcJsFile || !is_string($cdcJsFile) || empty($cdcJsFile)) { - $extraParams['cdc_script_not_found'] = true; - $extraParams['cdc_error_url'] = $moduleUri . 'views/js/cdc-error.js'; - } else { - $extraParams['cdc_url'] = $cdcJsFile; - } - /********************* * PrestaShop Account * * *******************/ @@ -116,7 +101,7 @@ public function indexAction(): Response 'You do not have permission to add this.', 'Admin.Notifications.Error' ), - ] + $extraParams + ] ); } diff --git a/src/Traits/Hooks/UseActionAdminControllerSetMedia.php b/src/Traits/Hooks/UseActionAdminControllerSetMedia.php index 648df0132..5981368a9 100644 --- a/src/Traits/Hooks/UseActionAdminControllerSetMedia.php +++ b/src/Traits/Hooks/UseActionAdminControllerSetMedia.php @@ -116,7 +116,8 @@ private function loadCdcMedia(): void } if ( !Tab::mayDisplayRecommendedModules($controllerName) && - !in_array($controllerName, self::CONTROLLERS_WITH_CDC_SCRIPT) + !in_array($controllerName, self::CONTROLLERS_WITH_CDC_SCRIPT) && + $controllerName !== 'AdminPsMboModule' ) { return; } diff --git a/views/templates/admin/controllers/module_catalog/catalog.html.twig b/views/templates/admin/controllers/module_catalog/catalog.html.twig index 1d1528be7..9dd92c025 100644 --- a/views/templates/admin/controllers/module_catalog/catalog.html.twig +++ b/views/templates/admin/controllers/module_catalog/catalog.html.twig @@ -20,13 +20,6 @@ {% block javascripts %} {{ parent() }} - - - {% if cdc_script_not_found is defined and cdc_script_not_found is same as(true) %} - - {% else %} - - {% endif %} {% endblock %} -{% block stylesheets %} - {{ parent() }} - -{% endblock %} - {% block content %}