![]() 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/ShipperAccount/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Controller\Adminhtml\ShipperAccount; use Extmag\Shiplab\Controller\Adminhtml\ShipperAccount; use Exception; use Magento\Backend\Model\View\Result\Redirect; class Delete extends ShipperAccount { /** * Authorization level of a basic admin session * * @see _isAllowed() */ public const ADMIN_RESOURCE = 'Extmag_Shiplab::shiplab_shipperaccount_delete'; /** * @return Redirect */ public function execute() { // check if we know what should be deleted $id = $this->getRequest()->getParam('entity_id'); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); if ($id) { $title = ""; try { $model = $this->shipperAccountRepository->getById($id); $title = $model->getTitle(); $this->shipperAccountRepository->delete($model); // display success message $this->messageManager->addSuccessMessage(__('The Shipper Account has been deleted.')); // go to grid $this->_eventManager->dispatch('adminhtml_extmag_shiplab_shipperaccount_on_delete', [ 'title' => $title, 'status' => 'success', ]); return $resultRedirect->setPath('*/*/'); } catch (Exception $e) { $this->_eventManager->dispatch( 'adminhtml_extmag_shiplab_shipperaccount_on_delete', ['title' => $title, 'status' => 'fail'] ); // display error message $this->messageManager->addErrorMessage(__('Can\'t delete the Shipper Account')); // go back to edit form return $resultRedirect->setPath('*/*/edit', ['entity_id' => $id]); } } // display error message $this->messageManager->addErrorMessage(__('We can\'t find a Shipper Account to delete.')); // go to grid return $resultRedirect->setPath('*/*/'); } }