Spamworldpro Mini Shell
Spamworldpro


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/Pickup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/shiplab/Controller/Adminhtml/Pickup/Delete.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\Shiplab\Controller\Adminhtml\Pickup;

use Extmag\Shiplab\Controller\Adminhtml\Pickup;
use Exception;
use Magento\Backend\Model\View\Result\Redirect;

class Delete extends Pickup
{
    /**
     * Authorization level of a basic admin session
     *
     * @see _isAllowed()
     */
    public const ADMIN_RESOURCE = 'Extmag_Shiplab::shiplab_pickup_delete';

    /**
     * @return Redirect
     */
    public function execute()
    {
        $id = $this->getRequest()->getParam('entity_id');
        /** @var Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        if ($id) {
            try {
                $model = $this->pickupRepository->getById($id);
                $prn = $model->getMasterId();
                $labelIds = $model->getLabelIds();
                if (!empty($prn) && !empty($labelIds)) {
                    $response = $this->pickup->makeDataAndCancelPickup($model->getCarrierCode(), [$model]);
                }
                $this->pickupRepository->delete($model);

                $this->messageManager->addSuccessMessage(__('The pickup has been deleted.'));

                if (!empty($response['error'])) {
                    $this->messageManager->addNoticeMessage(
                        __('The pickup has not been deleted from ' . strtoupper($model->getCarrierCode()) . ' server.')
                    );
                }

                // go to grid
                $this->_eventManager->dispatch(
                    'adminhtml_extmag_shiplab_pickup_on_delete',
                    [
                        'prn' => $prn,
                        'label_ids' => $labelIds,
                        'status' => 'success',
                    ]
                );

                return $resultRedirect->setPath('*/*/');
            } catch (Exception $e) {
                $this->_eventManager->dispatch(
                    'adminhtml_extmag_shiplab_pickup_on_delete',
                    ['id' => $id, 'status' => 'fail']
                );
                // display error message
                $this->messageManager->addErrorMessage($e->getMessage());
                // go back to edit form
                return $resultRedirect->setPath('*/*/edit', ['entity_id' => $id]);
            }
        }

        // display error message
        $this->messageManager->addErrorMessage(__('We can\'t find a pickup to delete.'));

        // go to grid
        return $resultRedirect->setPath('*/*/');
    }
}

Spamworldpro Mini