![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/extmag/shiplab/Controller/Adminhtml/Logs/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Controller\Adminhtml\Logs; use Extmag\Shiplab\Model\LogsRepository as EmodelRepository; use Extmag\Shiplab\Model\ResourceModel\Logs\Collection; use Extmag\Shiplab\Model\ResourceModel\Logs\CollectionFactory; use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Ui\Component\MassAction\Filter; class MassDelete extends Action { /** * Authorization level of a basic admin session * * @see _isAllowed() */ public const ADMIN_RESOURCE = 'Extmag_Shiplab::shiplab_logs_delete'; /** * @var Filter */ protected $filter; /** * @var CollectionFactory */ protected $collectionFactory; /** * @var EmodelRepository */ protected $modelRepository; /** * @param Context $context * @param Filter $filter * @param CollectionFactory $collectionFactory * @param EmodelRepository $modelRepository */ public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory, EmodelRepository $modelRepository ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); $this->modelRepository = $modelRepository; } /** * @return Redirect * @throws LocalizedException|Exception */ public function execute() { /** * @var Collection $collection */ $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = 0; foreach ($collection->getAllIds() as $id) { $this->modelRepository->deleteById($id); $collectionSize++; } $this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize)); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } }