[Added] module-activated check

since its a private method in OXID7
Cette révision appartient à :
MaxBuhe01 2024-10-05 19:01:00 +02:00
Parent 9fde587cfd
révision a702a211ef
2 fichiers modifiés avec 28 ajouts et 4 suppressions

Voir le fichier

@ -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;
}

Voir le fichier

@ -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;
}
}