isCampaignActive()) { return false; } return !in_array($this->request->getFullActionName(), $this->getExcludedHandles(), true); } public function isCampaignActive(): bool { $identifier = $this->getCmsBlockIdentifier(); $store = $this->storeManager->getStore(); if (!$this->isEnabled() || $identifier === '' || !$this->timezone->isScopeDateInInterval( $store, $this->getValue('start_date') ?: null, $this->getValue('end_date') ?: null ) ) { return false; } try { return $this->blockByIdentifier->execute($identifier, (int)$store->getId())->isActive(); } catch (NoSuchEntityException) { return false; } } public function isRegistrationNewsletterCouponPromotion(): bool { return $this->getValue('promotion_type') === PromotionType::REGISTRATION_NEWSLETTER_COUPON; } public function isEnabled(): bool { return $this->scopeConfig->isSetFlag( self::XML_PATH_PREFIX . 'enabled', ScopeInterface::SCOPE_STORE ); } public function getCmsBlockIdentifier(): string { return trim($this->getValue('cms_block_identifier')); } public function getWebsiteId(): int { return (int)$this->storeManager->getStore()->getWebsiteId(); } public function getDisplayDelay(): int { return min(60000, max(0, (int)$this->getValue('display_delay'))); } public function getFrequency(): string { $frequency = $this->getValue('frequency'); $allowed = [Frequency::ALWAYS, Frequency::SESSION, Frequency::DAILY, Frequency::CAMPAIGN]; return in_array($frequency, $allowed, true) ? $frequency : Frequency::DAILY; } public function getAudience(): string { return $this->getValue('audience') === Audience::ALL ? Audience::ALL : Audience::GUEST; } public function getCampaignVersion(): int { return max(1, (int)$this->getValue('campaign_version')); } /** @return string[] */ private function getExcludedHandles(): array { return array_values(array_unique(array_filter(array_map( static fn(string $handle): string => trim($handle), preg_split('/[\r\n,]+/', $this->getValue('excluded_handles')) ?: [] )))); } private function getValue(string $field): string { return (string)$this->scopeConfig->getValue( self::XML_PATH_PREFIX . $field, ScopeInterface::SCOPE_STORE ); } }