ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?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\Controller\Consent\Customer;
|
||||
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Plumrocket\CookieConsent\Helper\Config;
|
||||
use Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Log consent and clear rejected cookies
|
||||
*/
|
||||
class Update extends Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Serialize\SerializerInterface
|
||||
*/
|
||||
private $jsonSerializer;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Helper\Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam
|
||||
*/
|
||||
private $createSettingsFromParam;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\App\Action\Context $context
|
||||
* @param \Magento\Framework\Serialize\SerializerInterface $jsonSerializer
|
||||
* @param \Plumrocket\CookieConsent\Helper\Config $config
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* @param \Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam $createSettingsFromParam
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
SerializerInterface $jsonSerializer,
|
||||
Config $config,
|
||||
LoggerInterface $logger,
|
||||
CreateSettingsFromParam $createSettingsFromParam
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->jsonSerializer = $jsonSerializer;
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
$this->createSettingsFromParam = $createSettingsFromParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute controller.
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
|
||||
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
||||
|
||||
$consentDetailJson = $this->getRequest()->getContent();
|
||||
|
||||
if (! $consentDetailJson || ! $this->config->isModuleEnabled()) {
|
||||
$resultJson->setHttpResponseCode(404);
|
||||
$response = ['message' => __('Not found.')];
|
||||
return $resultJson->setData($response);
|
||||
}
|
||||
|
||||
try {
|
||||
$consentDetail = $this->jsonSerializer->unserialize($consentDetailJson);
|
||||
$acceptedKeys = $consentDetail['acceptedKeys'] ?: [];
|
||||
$settings = $this->createSettingsFromParam->execute($acceptedKeys);
|
||||
|
||||
$this->_eventManager->dispatch(
|
||||
'pr_cookie_consent_update',
|
||||
['settings' => $settings]
|
||||
);
|
||||
$response = ['message' => __('Log successfully added.')];
|
||||
} catch (LocalizedException $e) {
|
||||
$resultJson->setHttpResponseCode(400);
|
||||
$response = [
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
$resultJson->setHttpResponseCode(400);
|
||||
$response = ['message' => __('Something went wrong.')];
|
||||
}
|
||||
|
||||
return $resultJson->setData($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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\Controller\Consent\Guest;
|
||||
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Plumrocket\CookieConsent\Helper\Config;
|
||||
use Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam;
|
||||
|
||||
/**
|
||||
* Log consent and clear rejected cookies
|
||||
*/
|
||||
class Update extends Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Serialize\SerializerInterface
|
||||
*/
|
||||
private $jsonSerializer;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Helper\Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam
|
||||
*/
|
||||
private $createSettingsFromParam;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\App\Action\Context $context
|
||||
* @param \Magento\Framework\Serialize\SerializerInterface $jsonSerializer
|
||||
* @param \Plumrocket\CookieConsent\Helper\Config $config
|
||||
* @param \Plumrocket\CookieConsent\Model\Consent\CreateSettingsFromParam $createSettingsFromParam
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
SerializerInterface $jsonSerializer,
|
||||
Config $config,
|
||||
CreateSettingsFromParam $createSettingsFromParam
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->jsonSerializer = $jsonSerializer;
|
||||
$this->config = $config;
|
||||
$this->createSettingsFromParam = $createSettingsFromParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute controller.
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
|
||||
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
||||
|
||||
$consentDetailJson = $this->getRequest()->getContent();
|
||||
|
||||
if (! $consentDetailJson || ! $this->config->isModuleEnabled()) {
|
||||
$resultJson->setHttpResponseCode(404);
|
||||
$response = ['message' => __('Not found.')];
|
||||
return $resultJson->setData($response);
|
||||
}
|
||||
|
||||
$consentDetail = $this->jsonSerializer->unserialize($consentDetailJson);
|
||||
$acceptedKeys = $consentDetail['acceptedKeys'] ?: [];
|
||||
$settings = $this->createSettingsFromParam->execute($acceptedKeys);
|
||||
|
||||
$this->_eventManager->dispatch(
|
||||
'pr_cookie_consent_update',
|
||||
['settings' => $settings]
|
||||
);
|
||||
|
||||
$response = ['Update processed.'];
|
||||
|
||||
return $resultJson->setData($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user