![]() 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/ShippingMethods/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Controller\Adminhtml\ShippingMethods; use Extmag\Shiplab\Model\ResourceModel\ShippingMethods\CollectionFactory; use Extmag\Shiplab\Model\ShippingMethods; use Extmag\Shiplab\Model\ShippingMethodsRepository; 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 MassStatus extends Action { /** * Authorization level of a basic admin session * * @see _isAllowed() */ public const ADMIN_RESOURCE = 'Extmag_Shiplab::shiplab_shippingmethods_save'; /** * @var Filter */ protected $filter; /** * @var CollectionFactory */ protected $collectionFactory; /** * @var ShippingMethodsRepository */ protected $shippingMethodsRepository; /** * @param Context $context * @param Filter $filter * @param CollectionFactory $collectionFactory * @param ShippingMethodsRepository $shippingMethodsRepository */ public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory, ShippingMethodsRepository $shippingMethodsRepository ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); $this->shippingMethodsRepository = $shippingMethodsRepository; } /** * @return Redirect * @throws LocalizedException|Exception */ public function execute() { $status = (int)$this->getRequest()->getParam('active', 0); $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); /** * @var ShippingMethods $page */ foreach ($collection as $page) { $page->setStatus($status); $this->shippingMethodsRepository->save($page); } $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('*/*/'); } }