81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* @package Plumrocket_GlobalPrivacyControl
|
|
* @copyright Copyright (c) 2025 Plumrocket Inc.
|
|
* @license https://plumrocket.com/license End-user License Agreement
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Plumrocket\GlobalPrivacyControl\Helper\Config;
|
|
|
|
use Magento\Cms\Model\Template\FilterProvider;
|
|
use Magento\Framework\App\Helper\Context;
|
|
use Plumrocket\Base\Api\ConfigUtilsInterface;
|
|
use Plumrocket\Base\Helper\ConfigUtils;
|
|
use Plumrocket\GlobalPrivacyControl\Helper\Config;
|
|
|
|
class OptOutNotification extends ConfigUtils
|
|
{
|
|
private const XML_PATH_OPT_OUT_NOTIFICATION_ENABLED = 'pr_gpc/opt_out_notification/enabled';
|
|
private const XML_PATH_OPT_OUT_NOTIFICATION_CONTENT = 'pr_gpc/opt_out_notification/text';
|
|
|
|
/**
|
|
* @var \Magento\Cms\Model\Template\FilterProvider
|
|
*/
|
|
private $filterProvider;
|
|
|
|
/**
|
|
* @var \Plumrocket\Base\Api\ConfigUtilsInterface
|
|
*/
|
|
private $configUtils;
|
|
|
|
/**
|
|
* @var \Plumrocket\GlobalPrivacyControl\Helper\Config
|
|
*/
|
|
private $config;
|
|
|
|
/**
|
|
* @param \Magento\Framework\App\Helper\Context $context
|
|
* @param \Magento\Cms\Model\Template\FilterProvider $filterProvider
|
|
* @param \Plumrocket\Base\Api\ConfigUtilsInterface $configUtils
|
|
* @param \Plumrocket\GlobalPrivacyControl\Helper\Config $config
|
|
*/
|
|
public function __construct(
|
|
Context $context,
|
|
FilterProvider $filterProvider,
|
|
ConfigUtilsInterface $configUtils,
|
|
Config $config
|
|
) {
|
|
parent::__construct($context);
|
|
$this->filterProvider = $filterProvider;
|
|
$this->configUtils = $configUtils;
|
|
$this->config = $config;
|
|
}
|
|
|
|
/**
|
|
* @param $store
|
|
* @param $scope
|
|
* @return bool
|
|
*/
|
|
public function isEnabled($store = null, $scope = null): bool
|
|
{
|
|
if (! $this->config->isModuleEnabled()) {
|
|
return false;
|
|
}
|
|
|
|
return $this->configUtils->isSetFlag(self::XML_PATH_OPT_OUT_NOTIFICATION_ENABLED, $store, $scope);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getNotificationText($store = null, $scope = null): string
|
|
{
|
|
$text = $this->getConfig(self::XML_PATH_OPT_OUT_NOTIFICATION_CONTENT, $store, $scope);
|
|
|
|
return $this->filterProvider->getBlockFilter()
|
|
->filter($text);
|
|
}
|
|
}
|