serializer = $serializer; $this->isMatchUrl = $isMatchUrl; $this->filterProvider = $filterProvider; $this->cookieNoticeConfig = $cookieNoticeConfig; } /** * @return array */ public function getJsComponentConfig(): array { return [ 'displayStyle' => $this->cookieNoticeConfig->getDisplayStyle(), 'acceptButtonConfig' => $this->prepareButtonConfig($this->cookieNoticeConfig->getAcceptButtonConfig()), 'declineButtonConfig' => $this->prepareButtonConfig($this->cookieNoticeConfig->getDeclineButtonConfig()), 'settingsButtonConfig' => $this->prepareButtonConfig($this->cookieNoticeConfig->getSettingsButtonConfig()), 'statusCookieName' => self::COOKIE_NAME_STATUS, 'noticeTitle' => $this->cookieNoticeConfig->getTitle(), 'noticeTextHtml' => $this->filterProvider->getBlockFilter()->filter( $this->cookieNoticeConfig->getText() ), 'design' => [ 'titleColor' => $this->cookieNoticeConfig->getTitleColor(), 'textColor' => $this->cookieNoticeConfig->getTextColor(), 'backgroundColor' => $this->cookieNoticeConfig->getBackgroundColor(), 'overlayBackgroundColor' => $this->cookieNoticeConfig->getOverlayBackgroundColor(), 'overlayBlur' => $this->cookieNoticeConfig->getIsNeedBlurOverlay(), ], ]; } /** * @return bool */ public function isAllowedPage(): bool { return ! $this->isMatchUrl->executeList( $this->_urlBuilder->getCurrentUrl(), $this->cookieNoticeConfig->getUrlsToHide() ); } /** * @return false|string */ public function getJsLayout() { if (isset($this->jsLayout['components']['pr-cookie-notice'])) { $this->jsLayout['components']['pr-cookie-notice'] = array_merge_recursive( $this->jsLayout['components']['pr-cookie-notice'], $this->getJsComponentConfig() ); } else { $this->jsLayout['components']['pr-cookie-notice'] = $this->getJsComponentConfig(); } return $this->jsLayout ? $this->serializer->serialize($this->jsLayout) : ''; } /** * @param array $config * @return array */ private function prepareButtonConfig(array $config): array { if (isset($config['enabled'])) { $config['enabled'] = (bool) $config['enabled']; } return $config; } }