configUtils = $configUtils; $this->serializer = $serializer; } /** * Check if module is enabled. * * @param null $store * @param null $scope * @return bool */ public function isModuleEnabled($store = null, $scope = null): bool { return $this->configUtils->isSetFlag( self::XML_PATH_IS_ENABLED, $store, $scope ); } /** * @param null $store * @param null $scope * @return bool */ public function canUseCookieBeforeOptIn($store = null, $scope = null): bool { return $this->configUtils->isSetFlag( self::XML_PATH_USE_COOKIE_BEFORE_OPT_IN, $store, $scope ); } /** * @param null $store * @param null $scope * @return bool */ public function canBlockUnknownCookie($store = null, $scope = null): bool { return $this->configUtils->isSetFlag( self::XML_PATH_BLOCK_UNKNOWN_COOKIE, $store, $scope ); } /** * @param null $store * @param null $scope * @return int */ public function getConsentExpiry($store = null, $scope = null): int { return (int) $this->configUtils->getConfig(self::XML_PATH_CONSENT_EXPIRY, $store, $scope); } /** * @param null $store * @param null $scope * @return bool */ public function reloadAfterAccept($store = null, $scope = null): bool { return $this->configUtils->isSetFlag(self::XML_PATH_RELOAD_AFTER_ACCEPT, $store, $scope); } /** * @param null $store * @param null $scope * @return bool */ public function reloadAfterDecline($store = null, $scope = null): bool { return $this->configUtils->isSetFlag(self::XML_PATH_RELOAD_AFTER_DECLINE, $store, $scope); } /** ------ GMT ------- */ /** * @param null $store * @param null $scope * @return bool */ public function isGtmEnabled($store = null, $scope = null): bool { return $this->configUtils->isSetFlag(self::XML_PATH_GTM_ENABLED, $store, $scope); } /** * @param null $store * @param null $scope * @return string */ public function getGmtAssociatedCategoryKey($store = null, $scope = null): string { return (string) $this->configUtils->getConfig(self::XML_PATH_GTM_CATEGORY_KEY, $store, $scope); } /** * @param null $store * @param null $scope * @return string */ public function getGtmContainerId($store = null, $scope = null): string { return trim((string) $this->configUtils->getConfig(self::XML_PATH_GTM_CONTAINER_ID, $store, $scope)); } /** * @param $store * @param $scope * @return bool */ public function isGtmServerSideTaggingEnabled($store = null, $scope = null): bool { return $this->configUtils->isSetFlag(self::XML_PATH_GTM_SERVER_SIDE_TAGGING, $store, $scope); } /** * @param $store * @param $scope * @return string */ public function getGtmServerBaseUrl($store = null, $scope = null): string { if (! $this->isGtmServerSideTaggingEnabled($store, $scope)) { return 'https://www.googletagmanager.com'; } return trim((string) $this->configUtils->getConfig(self::XML_PATH_GTM_SERVER_URL, $store, $scope), ' \/'); } /** * Check if gtm consent mode enabled * * @param null $store * @param null $scope * @return bool */ public function isGtmConsentModeEnabled($store = null, $scope = null): bool { return $this->configUtils->isSetFlag(self::XML_PATH_GTM_CONSENT_MODE_ENABLED, $store, $scope); } /** * Retrieve gtm consent types configurations * * @param null $store * @param null $scope * @return array */ public function getGtmConsentTypesConfig($store = null, $scope = null): array { $config = $this->configUtils->getConfig(self::XML_PATH_GTM_CONSENT_TYPES, $store, $scope); if (is_string($config)) { $config = $this->serializer->unserialize($config); } return $config ?: []; } }