From a702a211ef8c53a75a237336ffddfe48a9be03f0 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Sat, 5 Oct 2024 19:01:00 +0200 Subject: [PATCH] [Added] module-activated check since its a private method in OXID7 --- Application/Model/ManagerHandler.php | 4 ++-- Modules/Core/ViewConfig.php | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Application/Model/ManagerHandler.php b/Application/Model/ManagerHandler.php index 3bb71ca..ee0e577 100644 --- a/Application/Model/ManagerHandler.php +++ b/Application/Model/ManagerHandler.php @@ -17,7 +17,7 @@ class ManagerHandler /** @var ManagerTypes $oManagerTypes */ $oManagerTypes = oxNew(ManagerTypes::class); - /** @var ViewConfig $oViewConfig */ + /** @var ViewConfig|\D3\GoogleAnalytics4\Modules\Core\ViewConfig $oViewConfig */ $oViewConfig = oxNew(ViewConfig::class); $aManagerList = $oManagerTypes->getManagerList(); @@ -27,7 +27,7 @@ class ManagerHandler } foreach ($aManagerList as $shopModuleId => $publicCMPName){ - if ($oViewConfig->isModuleActive($shopModuleId)){ + if ($oViewConfig->d3IsModuleActive($shopModuleId)){ $this->d3SaveShopConfVar($shopModuleId); return $shopModuleId; } diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index e2fc6a6..9945905 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -18,9 +18,11 @@ use D3\GoogleAnalytics4\Application\Model\ManagerHandler; use D3\GoogleAnalytics4\Application\Model\ManagerTypes; use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Core\Config; -use OxidEsales\Eshop\Application\Model\User;use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Core\Registry; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; -use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleConfigurationNotFoundException; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -256,4 +258,26 @@ class ViewConfig extends ViewConfig_parent return (bool) ($sCMPPubName === Usercentrics::sExternalIncludationInternalName or $sCMPPubName === Usercentrics::sModuleIncludationInternalName); } + + /** + * @return bool + */ + public function d3IsModuleActive(string $sModuleId) :bool + { + /** @var ModuleActivationBridgeInterface $moduleActivationBridge */ + $moduleActivationBridge = $this + ->getContainer() + ->get(ModuleActivationBridgeInterface::class); + + try { + $isActiveBool = $moduleActivationBridge->isActive( + $sModuleId, + Registry::getConfig()->getShopId() + ); + }catch (\Exception|ModuleConfigurationNotFoundException $e){ + return false; + } + + return (bool) $isActiveBool; + } } \ No newline at end of file