64 lines
1.7 KiB
PHP
64 lines
1.7 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\ViewModel;
|
|
|
|
use Magento\Framework\Escaper;
|
|
use Magento\Framework\View\Element\Block\ArgumentInterface;
|
|
use Plumrocket\GlobalPrivacyControl\Helper\Config\OptOutNotification as OptOutNotificationConfig;
|
|
|
|
class OptOutNotification implements ArgumentInterface
|
|
{
|
|
/**
|
|
* @var \Plumrocket\GlobalPrivacyControl\Helper\Config\OptOutNotification
|
|
*/
|
|
private $optOutNotificationConfig;
|
|
|
|
/**
|
|
* @var \Magento\Framework\Escaper
|
|
*/
|
|
private $escaper;
|
|
|
|
/**
|
|
* @param \Plumrocket\GlobalPrivacyControl\Helper\Config\OptOutNotification $optOutNotificationConfig
|
|
* @param \Magento\Framework\Escaper $escaper
|
|
*/
|
|
public function __construct(
|
|
OptOutNotificationConfig $optOutNotificationConfig,
|
|
Escaper $escaper
|
|
) {
|
|
$this->optOutNotificationConfig = $optOutNotificationConfig;
|
|
$this->escaper = $escaper;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isEnabled(): bool
|
|
{
|
|
return $this->optOutNotificationConfig->isEnabled();
|
|
}
|
|
|
|
/**
|
|
* @param bool $escapeForJs
|
|
* @return string
|
|
*/
|
|
public function getNotificationHtml(bool $escapeForJs = false): string
|
|
{
|
|
$html = <<<HTML
|
|
<div class="pr-gpc-notification-wrap">
|
|
{$this->optOutNotificationConfig->getNotificationText()}
|
|
</div>
|
|
HTML;
|
|
return $escapeForJs
|
|
? $this->escaper->escapeJs($html)
|
|
: $html;
|
|
}
|
|
}
|