61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* @package Plumrocket_CookieConsent
|
|
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
|
* @license https://plumrocket.com/license End-user License Agreement
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Plumrocket\CookieConsent\Plugin\Cookie;
|
|
|
|
use Magento\Cookie\Helper\Cookie;
|
|
use Plumrocket\CookieConsent\Api\CanManageCookieInterface;
|
|
use Plumrocket\CookieConsent\Helper\Config;
|
|
|
|
/**
|
|
* @since 1.0.0
|
|
*/
|
|
class RestrictionMode
|
|
{
|
|
/**
|
|
* @var \Plumrocket\CookieConsent\Api\CanManageCookieInterface
|
|
*/
|
|
private $canManageCookie;
|
|
|
|
/**
|
|
* @var \Plumrocket\CookieConsent\Helper\Config
|
|
*/
|
|
private $config;
|
|
|
|
/**
|
|
* RestrictionMode constructor.
|
|
*
|
|
* @param \Plumrocket\CookieConsent\Api\CanManageCookieInterface $canManageCookie
|
|
* @param \Plumrocket\CookieConsent\Helper\Config $config
|
|
*/
|
|
public function __construct(
|
|
CanManageCookieInterface $canManageCookie,
|
|
Config $config
|
|
) {
|
|
$this->canManageCookie = $canManageCookie;
|
|
$this->config = $config;
|
|
}
|
|
|
|
/**
|
|
* Change magento restriction mode.
|
|
*
|
|
* @param \Magento\Cookie\Helper\Cookie $subject
|
|
* @param string|null|bool $result
|
|
* @return bool
|
|
*/
|
|
public function afterIsCookieRestrictionModeEnabled(Cookie $subject, $result)
|
|
{
|
|
if ($this->config->isModuleEnabled()) {
|
|
return $this->canManageCookie->execute();
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|