ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AbstractCategory extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::cookie_categories';
|
||||
|
||||
/**
|
||||
* Init Consent Location
|
||||
*
|
||||
* @param \Magento\Backend\Model\View\Result\Page $resultPage
|
||||
* @return \Magento\Backend\Model\View\Result\Page
|
||||
*/
|
||||
protected function initBreadcrumbAndMenu($resultPage): Page
|
||||
{
|
||||
$resultPage->setActiveMenu(self::ADMIN_RESOURCE)
|
||||
->addBreadcrumb(__('Cookie Consent'), __('Cookie Consent'))
|
||||
->addBreadcrumb(__('Cookie Categories'), __('Cookie Categories'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Model\AbstractExtensibleModel;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
abstract class AbstractEavSave extends Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* AbstractEavSave constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StoreManagerInterface $storeManager
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->storeManager = $storeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init current store.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
protected function initCurrentStore(): int
|
||||
{
|
||||
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
||||
$store = $this->storeManager->getStore($storeId);
|
||||
$this->storeManager->setCurrentStore($store->getCode());
|
||||
return $storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check "Use Default Value" checkboxes values
|
||||
*
|
||||
* @param array $postData
|
||||
* @param \Magento\Framework\Model\AbstractExtensibleModel $model
|
||||
* @return $this
|
||||
*/
|
||||
protected function prepareUseDefault(array $postData, AbstractExtensibleModel $model)
|
||||
{
|
||||
if (isset($postData['use_default']) && ! empty($postData['use_default'])) {
|
||||
foreach ($postData['use_default'] as $attributeCode => $attributeValue) {
|
||||
if ($attributeValue) {
|
||||
$model->setData($attributeCode, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AbstractItem extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::cookie_categories';
|
||||
|
||||
/**
|
||||
* Init Consent Location
|
||||
*
|
||||
* @param \Magento\Backend\Model\View\Result\Page $resultPage
|
||||
* @return \Magento\Backend\Model\View\Result\Page
|
||||
*/
|
||||
protected function initBreadcrumbAndMenu($resultPage): Page
|
||||
{
|
||||
$resultPage->setActiveMenu(self::ADMIN_RESOURCE)
|
||||
->addBreadcrumb(__('Cookie Consent'), __('Cookie Consent'))
|
||||
->addBreadcrumb(__('Cookie'), __('Cookie'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?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\Controller\Adminhtml\Category;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Store\Model\StoreFactory;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Api\CategoryRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Model\Category;
|
||||
use Plumrocket\CookieConsent\Model\CategoryFactory;
|
||||
use Plumrocket\CookieConsent\Ui\Locator\CategoryLocatorInterface;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\CategoryFactory
|
||||
*/
|
||||
private $categoryFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreFactory
|
||||
*/
|
||||
private $storeFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Ui\Locator\CategoryLocatorInterface
|
||||
*/
|
||||
private $categoryLocator;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface
|
||||
*/
|
||||
private $categoryRepository;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\CookieConsent\Model\CategoryFactory $categoryFactory
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Magento\Store\Model\StoreFactory $storeFactory
|
||||
* @param \Plumrocket\CookieConsent\Ui\Locator\CategoryLocatorInterface $categoryLocator
|
||||
* @param \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface $categoryRepository
|
||||
*/
|
||||
public function __construct(
|
||||
CategoryFactory $categoryFactory,
|
||||
StoreManagerInterface $storeManager,
|
||||
StoreFactory $storeFactory,
|
||||
CategoryLocatorInterface $categoryLocator,
|
||||
CategoryRepositoryInterface $categoryRepository
|
||||
) {
|
||||
$this->categoryFactory = $categoryFactory;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->storeFactory = $storeFactory;
|
||||
$this->categoryLocator = $categoryLocator;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cookie category based on user request
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @return \Plumrocket\CookieConsent\Model\Category
|
||||
*/
|
||||
public function build(RequestInterface $request): Category
|
||||
{
|
||||
$storeId = (int) $request->getParam('store', 0);
|
||||
$categoryId = (int) $request->getParam('id');
|
||||
|
||||
$store = $this->storeManager->getStore($storeId);
|
||||
$this->storeManager->setCurrentStore($store->getCode());
|
||||
|
||||
if ($categoryId) {
|
||||
try {
|
||||
$category = $this->categoryRepository->getById($categoryId, $storeId);
|
||||
} catch (NoSuchEntityException $e) {
|
||||
/** @var \Plumrocket\CookieConsent\Model\Category $category */
|
||||
$category = $this->categoryFactory->create();
|
||||
}
|
||||
} else {
|
||||
/** @var \Plumrocket\CookieConsent\Model\Category $category */
|
||||
$category = $this->categoryFactory->create();
|
||||
}
|
||||
|
||||
/** @var \Magento\Store\Model\Store $store */
|
||||
$store = $this->storeFactory->create();
|
||||
$store->load($storeId);
|
||||
|
||||
$category->setStoreId(null !== $store->getId() ? (int) $store->getId() : null);
|
||||
|
||||
$this->categoryLocator->setStore($store);
|
||||
$this->categoryLocator->setCategory($category);
|
||||
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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\Controller\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Plumrocket\CookieConsent\Api\CategoryRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Delete extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface
|
||||
*/
|
||||
private $cookieCategoryRepository;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface $cookieCategoryRepository
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
CategoryRepositoryInterface $cookieCategoryRepository
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->cookieCategoryRepository = $cookieCategoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
if ($id) {
|
||||
try {
|
||||
$this->cookieCategoryRepository->deleteById($id);
|
||||
$this->messageManager->addSuccessMessage(__('You deleted the cookie category.'));
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->messageManager->addErrorMessage(__('We can\'t find a cookie category to delete.'));
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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\Controller\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractCategory;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Edit extends AbstractCategory
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Controller\Adminhtml\Category\Builder
|
||||
*/
|
||||
private $categoryBuilder;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Category\Builder $categoryBuilder
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StoreManagerInterface $storeManager,
|
||||
Builder $categoryBuilder
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->storeManager = $storeManager;
|
||||
$this->categoryBuilder = $categoryBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
$store = $this->storeManager->getStore($storeId);
|
||||
$this->storeManager->setCurrentStore($store->getCode());
|
||||
|
||||
$category = $this->categoryBuilder->build($this->getRequest());
|
||||
|
||||
if ($id && ! $category->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This cookie category no longer exists.'));
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
|
||||
$this->initBreadcrumbAndMenu($resultPage)->addBreadcrumb(
|
||||
$id ? __('Edit Cookie Category') : __('New Cookie Category'),
|
||||
$id ? __('Edit Cookie Category') : __('New Cookie Category')
|
||||
);
|
||||
|
||||
$title = $resultPage->getConfig()->getTitle();
|
||||
|
||||
$title->prepend(__('Cookie Category'));
|
||||
$title->prepend($category->getId()
|
||||
? __('Edit Cookie Category "%1"', $category->getName())
|
||||
: __('New Cookie Category'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Plumrocket\CookieConsent\Api\Data\CategoryInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractCategory;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Index extends AbstractCategory
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\App\Request\DataPersistorInterface
|
||||
*/
|
||||
private $dataPersistor;
|
||||
|
||||
/**
|
||||
* Index constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
DataPersistorInterface $dataPersistor
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
|
||||
$this->initBreadcrumbAndMenu($resultPage)->getConfig()->getTitle()->prepend(__('Manage Cookie Categories'));
|
||||
$this->dataPersistor->clear(CategoryInterface::DATA_PERSISTOR_KEY);
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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\Adminhtml\Category;
|
||||
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractCategory;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NewAction extends AbstractCategory
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
|
||||
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
|
||||
|
||||
return $resultForward->forward('edit');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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\Controller\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Api\CategoryRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Api\Data\CategoryInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractEavSave;
|
||||
|
||||
class Save extends AbstractEavSave
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::cookie_categories';
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
private $categoryBuilder;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Request\DataPersistorInterface
|
||||
*/
|
||||
private $dataPersistor;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface
|
||||
*/
|
||||
private $categoryRepository;
|
||||
|
||||
/**
|
||||
* Save constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Category\Builder $categoryBuilder
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
|
||||
* @param \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface $categoryRepository
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Builder $categoryBuilder,
|
||||
StoreManagerInterface $storeManager,
|
||||
DataPersistorInterface $dataPersistor,
|
||||
CategoryRepositoryInterface $categoryRepository
|
||||
) {
|
||||
parent::__construct($context, $storeManager);
|
||||
$this->categoryBuilder = $categoryBuilder;
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$storeId = $this->initCurrentStore();
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$postData = $this->getRequest()->getPostValue();
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
if ($postData) {
|
||||
$category = $this->categoryBuilder->build($this->getRequest());
|
||||
$this->dataPersistor->set(CategoryInterface::DATA_PERSISTOR_KEY, $postData);
|
||||
|
||||
if ($id && ! $category->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This category no longer exists.'));
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
try {
|
||||
$category->addData($postData);
|
||||
|
||||
$this->prepareUseDefault($postData, $category);
|
||||
|
||||
$this->categoryRepository->save($category);
|
||||
$this->messageManager->addSuccessMessage(__('You saved the category.'));
|
||||
$this->dataPersistor->clear(CategoryInterface::DATA_PERSISTOR_KEY);
|
||||
|
||||
if ($this->getRequest()->getParam('back')) {
|
||||
return $resultRedirect->setPath(
|
||||
'*/*/edit',
|
||||
['id' => $category->getId(), '_current' => true]
|
||||
);
|
||||
}
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch (LocalizedException $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addExceptionMessage(
|
||||
$e,
|
||||
__('Something went wrong while saving the category.')
|
||||
);
|
||||
}
|
||||
|
||||
$this->dataPersistor->set(CategoryInterface::DATA_PERSISTOR_KEY, $postData);
|
||||
|
||||
return $resultRedirect->setPath('*/*/edit', [
|
||||
'id' => $this->getRequest()->getParam('id'),
|
||||
'store' => $storeId,
|
||||
]);
|
||||
}
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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\Controller\Adminhtml\Consent\Log;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Plumrocket\CookieConsent\Api\Data\ConsentLogInterface;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::consent_log';
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Request\DataPersistorInterface
|
||||
*/
|
||||
private $dataPersistor;
|
||||
|
||||
/**
|
||||
* Index constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
DataPersistorInterface $dataPersistor
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu(self::ADMIN_RESOURCE)
|
||||
->addBreadcrumb(__('Cookie Consent'), __('Cookie Consent'))
|
||||
->addBreadcrumb(__('Consent Log'), __('Consent Log'));
|
||||
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Cookie Consent Log'));
|
||||
$this->dataPersistor->clear(ConsentLogInterface::DATA_PERSISTOR_KEY);
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Store\Model\StoreFactory;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Model\Cookie;
|
||||
use Plumrocket\CookieConsent\Model\CookieFactory;
|
||||
use Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\CookieFactory
|
||||
*/
|
||||
private $cookieFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreFactory
|
||||
*/
|
||||
private $storeFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface
|
||||
*/
|
||||
private $cookieLocator;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CookieRepositoryInterface
|
||||
*/
|
||||
private $cookieRepository;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\CookieConsent\Model\CookieFactory $cookieFactory
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Magento\Store\Model\StoreFactory $storeFactory
|
||||
* @param \Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface $cookieLocator
|
||||
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
|
||||
*/
|
||||
public function __construct(
|
||||
CookieFactory $cookieFactory,
|
||||
StoreManagerInterface $storeManager,
|
||||
StoreFactory $storeFactory,
|
||||
CookieLocatorInterface $cookieLocator,
|
||||
CookieRepositoryInterface $cookieRepository
|
||||
) {
|
||||
$this->cookieFactory = $cookieFactory;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->storeFactory = $storeFactory;
|
||||
$this->cookieLocator = $cookieLocator;
|
||||
$this->cookieRepository = $cookieRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cookie item based on user request
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @return \Plumrocket\CookieConsent\Model\Cookie
|
||||
*/
|
||||
public function build(RequestInterface $request): Cookie
|
||||
{
|
||||
$storeId = (int) $request->getParam('store', 0);
|
||||
$cookieId = (int) $request->getParam('id');
|
||||
|
||||
$store = $this->storeManager->getStore($storeId);
|
||||
$this->storeManager->setCurrentStore($store->getCode());
|
||||
|
||||
if ($cookieId) {
|
||||
try {
|
||||
$cookie = $this->cookieRepository->getById($cookieId, $storeId);
|
||||
} catch (NoSuchEntityException $e) {
|
||||
/** @var \Plumrocket\CookieConsent\Model\Cookie $cookie */
|
||||
$cookie = $this->cookieFactory->create();
|
||||
}
|
||||
} else {
|
||||
/** @var \Plumrocket\CookieConsent\Model\Cookie $cookie */
|
||||
$cookie = $this->cookieFactory->create();
|
||||
}
|
||||
|
||||
/** @var \Magento\Store\Model\Store $store */
|
||||
$store = $this->storeFactory->create();
|
||||
$store->load($storeId);
|
||||
|
||||
$cookie->setStoreId(null !== $store->getId() ? (int) $store->getId() : null);
|
||||
|
||||
$this->cookieLocator->setStore($store);
|
||||
$this->cookieLocator->setCookie($cookie);
|
||||
|
||||
return $cookie;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Delete extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CookieRepositoryInterface
|
||||
*/
|
||||
private $cookieRepository;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
CookieRepositoryInterface $cookieRepository
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->cookieRepository = $cookieRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
if ($id) {
|
||||
try {
|
||||
$this->cookieRepository->deleteById($id);
|
||||
$this->messageManager->addSuccessMessage(__('You deleted the cookie.'));
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->messageManager->addErrorMessage(__('We can\'t find a cookie to delete.'));
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Edit extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder
|
||||
*/
|
||||
private $cookieBuilder;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder $cookieBuilder
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StoreManagerInterface $storeManager,
|
||||
Builder $cookieBuilder
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->storeManager = $storeManager;
|
||||
$this->cookieBuilder = $cookieBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
$store = $this->storeManager->getStore($storeId);
|
||||
$this->storeManager->setCurrentStore($store->getCode());
|
||||
|
||||
$cookie = $this->cookieBuilder->build($this->getRequest());
|
||||
|
||||
if ($id && ! $cookie->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This cookie cookie no longer exists.'));
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
|
||||
$this->initBreadcrumbAndMenu($resultPage)->addBreadcrumb(
|
||||
$id ? __('Edit Cookie') : __('New Cookie'),
|
||||
$id ? __('Edit Cookie') : __('New Cookie')
|
||||
);
|
||||
|
||||
$title = $resultPage->getConfig()->getTitle();
|
||||
|
||||
$title->prepend(__('Cookie Category'));
|
||||
$title->prepend($cookie->getId() ? __('Edit Cookie "%1"', $cookie->getName()) : __('New Cookie'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Adminhtml\Item;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Plumrocket\CookieConsent\Api\Data\CookieInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Index extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\App\Request\DataPersistorInterface
|
||||
*/
|
||||
private $dataPersistor;
|
||||
|
||||
/**
|
||||
* Index constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
DataPersistorInterface $dataPersistor
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
|
||||
$this->initBreadcrumbAndMenu($resultPage)->getConfig()->getTitle()->prepend(__('Manage Cookies'));
|
||||
$this->dataPersistor->clear(CookieInterface::DATA_PERSISTOR_KEY);
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
use Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MassDelete extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Ui\Component\MassAction\Filter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory
|
||||
*/
|
||||
private $collectionFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Ui\Component\MassAction\Filter $filter
|
||||
* @param \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory $collectionFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->filter = $filter;
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\Collection $collection */
|
||||
$collection = $this->filter->getCollection($this->collectionFactory->create());
|
||||
$collectionSize = $collection->getSize();
|
||||
|
||||
foreach ($collection->getItems() as $cookie) {
|
||||
$cookie->delete();
|
||||
}
|
||||
|
||||
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NewAction extends AbstractItem
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
|
||||
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
|
||||
|
||||
return $resultForward->forward('edit');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?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\Controller\Adminhtml\Item;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
|
||||
use Plumrocket\CookieConsent\Api\Data\CookieInterface;
|
||||
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractEavSave;
|
||||
use Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator;
|
||||
|
||||
class Save extends AbstractEavSave
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::cookies';
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
private $cookieBuilder;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Request\DataPersistorInterface
|
||||
*/
|
||||
private $dataPersistor;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface
|
||||
*/
|
||||
private $cookieRepository;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator
|
||||
*/
|
||||
private $durationDecorator;
|
||||
|
||||
/**
|
||||
* Save constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder $cookieBuilder
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
|
||||
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
|
||||
* @param \Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator $durationDecorator
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Builder $cookieBuilder,
|
||||
StoreManagerInterface $storeManager,
|
||||
DataPersistorInterface $dataPersistor,
|
||||
CookieRepositoryInterface $cookieRepository,
|
||||
DurationDecorator $durationDecorator
|
||||
) {
|
||||
parent::__construct($context, $storeManager);
|
||||
$this->cookieBuilder = $cookieBuilder;
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
$this->cookieRepository = $cookieRepository;
|
||||
$this->durationDecorator = $durationDecorator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$storeId = $this->initCurrentStore();
|
||||
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$postData = $this->getRequest()->getPostValue();
|
||||
$id = (int) $this->getRequest()->getParam('id');
|
||||
|
||||
if ($postData) {
|
||||
$cookie = $this->cookieBuilder->build($this->getRequest());
|
||||
$this->dataPersistor->set(CookieInterface::DATA_PERSISTOR_KEY, $postData);
|
||||
|
||||
if ($id && ! $cookie->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This cookie no longer exists.'));
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
try {
|
||||
$postData = $this->durationDecorator->serializeParams($postData);
|
||||
|
||||
$cookie->addData($postData);
|
||||
|
||||
$this->prepareUseDefault($postData, $cookie);
|
||||
|
||||
$this->cookieRepository->save($cookie);
|
||||
$this->messageManager->addSuccessMessage(__('You saved the cookie.'));
|
||||
$this->dataPersistor->clear(CookieInterface::DATA_PERSISTOR_KEY);
|
||||
|
||||
if ($this->getRequest()->getParam('back')) {
|
||||
return $resultRedirect->setPath(
|
||||
'*/*/edit',
|
||||
['id' => $cookie->getId(), '_current' => true]
|
||||
);
|
||||
}
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch (LocalizedException $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addExceptionMessage(
|
||||
$e,
|
||||
__('Something went wrong while saving the cookie.')
|
||||
);
|
||||
}
|
||||
|
||||
$this->dataPersistor->set(CookieInterface::DATA_PERSISTOR_KEY, $postData);
|
||||
|
||||
return $resultRedirect->setPath('*/*/edit', [
|
||||
'id' => $this->getRequest()->getParam('id'),
|
||||
'store' => $storeId,
|
||||
]);
|
||||
}
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -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