ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_CookieConsent
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\CookieConsent\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\InputException;
|
||||
use Magento\Framework\Stdlib\Cookie\FailureToSendException;
|
||||
use Plumrocket\CookieConsent\Model\Cookie\ClearRejected;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ClearRejectedCookie implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\Cookie\ClearRejected
|
||||
*/
|
||||
private $clearRejected;
|
||||
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\CookieConsent\Model\Cookie\ClearRejected $clearRejected
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
*/
|
||||
public function __construct(
|
||||
ClearRejected $clearRejected,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->clearRejected = $clearRejected;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear rejected cookies.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
try {
|
||||
$this->clearRejected->execute();
|
||||
} catch (InputException|FailureToSendException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_CookieConsent
|
||||
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\CookieConsent\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\AlreadyExistsException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Plumrocket\CookieConsent\Model\Consent\Logger;
|
||||
use Plumrocket\CookieConsent\Model\User\SetCookieConsentId;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @since 1.4.1
|
||||
*/
|
||||
class LogConsent implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\Consent\Logger
|
||||
*/
|
||||
private $consentLogger;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\User\SetCookieConsentId
|
||||
*/
|
||||
private $setCookieConsentId;
|
||||
|
||||
/**
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* @param \Plumrocket\CookieConsent\Model\Consent\Logger $consentLogger
|
||||
* @param \Plumrocket\CookieConsent\Model\User\SetCookieConsentId $setCookieConsentId
|
||||
*/
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
Logger $consentLogger,
|
||||
SetCookieConsentId $setCookieConsentId
|
||||
) {
|
||||
$this->logger = $logger;
|
||||
$this->consentLogger = $consentLogger;
|
||||
$this->setCookieConsentId = $setCookieConsentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log customer consent.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @throws \Magento\Framework\Exception\InputException
|
||||
* @throws \Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException
|
||||
* @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
|
||||
*/
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
try {
|
||||
$settings = $observer->getEvent()->getSettings();
|
||||
$consentLog = $this->consentLogger->log($settings);
|
||||
|
||||
$this->setCookieConsentId->execute((int) $consentLog->getId());
|
||||
} catch (AlreadyExistsException|NoSuchEntityException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_CookieConsent
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\CookieConsent\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Plumrocket\CookieConsent\Helper\Config;
|
||||
|
||||
/**
|
||||
* We create own block for cookie notice therefore need to remove old
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class RemoveMagentoNotice implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Helper\Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\CookieConsent\Helper\Config $config
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove cookie notice to replace it by ours.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
if (! $this->config->isModuleEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\View\LayoutInterface $layout
|
||||
*/
|
||||
$layout = $observer->getEvent()->getLayout();
|
||||
|
||||
$layout->getUpdate()->addUpdate('<referenceBlock name="cookie_notices" remove="true"/>');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user