ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -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('*/*/');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user