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/cartforge.co/app/code/Webkul/PrivateShop/Controller/Adminhtml/PrivateGroup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Webkul/PrivateShop/Controller/Adminhtml/PrivateGroup/Delete.php
<?php
/**
 * Webkul Software
 *
 * @category  Webkul
 * @package   Webkul_PrivateShop
 * @author    Webkul Software Private Limited
 * @copyright Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */

namespace Webkul\PrivateShop\Controller\Adminhtml\PrivateGroup;

use Webkul\PrivateShop\Api\Data\PrivateGroupInterfaceFactory;

class Delete extends \Webkul\PrivateShop\Controller\Adminhtml\PrivateGroup
{
    /**
     * Authorization level of a basic admin session
     *
     * @see _isAllowed()
     */
    public const ADMIN_RESOURCE = 'Webkul_PrivateShop::delete';

    /**
     * @var PrivateGroupInterfaceFactory
     */
    protected $privateGroupFactory;

    /**
     * @var \Webkul\PrivateShop\Helper\Groups
     */
    protected $helper;
    /**
     *
     * @param \Magento\Backend\App\Action\Context $context
     * @param \Magento\Framework\Registry $coreRegistry
     * @param \Webkul\PrivateShop\Helper\Groups $helper
     * @param PrivateGroupInterfaceFactory $privateGroupFactory
     */
    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\Registry $coreRegistry,
        \Webkul\PrivateShop\Helper\Groups $helper,
        PrivateGroupInterfaceFactory $privateGroupFactory
    ) {
        $this->privateGroupFactory = $privateGroupFactory;
        $this->helper = $helper;
        parent::__construct($context, $coreRegistry);
    }

    /**
     * Delete action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();
        // check if we know what should be deleted
        $id = $this->getRequest()->getParam('entity_id');
        if ($id) {
            try {
                $this->helper->setGroupIds([$id]);
                $this->helper->updateCustomerGroups();
                $this->helper->updatePrivateProducts();
                // init model and delete
                $model = $this->privateGroupFactory->create();
                $model->load($id);
                $model->delete();
                // display success message
                $this->messageManager->addSuccessMessage(__('You deleted the private group.'));
                // go to grid
                return $resultRedirect->setPath('*/*/');
            } catch (\Exception $e) {
                // display error message
                $this->messageManager->addErrorMessage($e->getMessage());
                // go back to edit form
                return $resultRedirect->setPath('*/*/edit', ['privategroup_id' => $id]);
            }
        }
        // display error message
        $this->messageManager->addErrorMessage(__('We can\'t find a private group to delete.'));
        // go to grid
        return $resultRedirect->setPath('*/*/');
    }
}

Spamworldpro Mini