43 lines
1.6 KiB
PHP
Executable File
43 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace IpSupply\CustomBanner\Controller\Adminhtml\Banner;
|
|
|
|
use Magento\Backend\App\Action;
|
|
use Magento\Backend\App\Action\Context;
|
|
use Magento\Framework\App\Action\HttpGetActionInterface;
|
|
use Magento\Framework\App\Action\HttpPostActionInterface;
|
|
use Magento\Framework\App\ObjectManager;
|
|
use Magento\Framework\Controller\ResultFactory;
|
|
|
|
class Delete extends Action implements HttpGetActionInterface, HttpPostActionInterface {
|
|
protected $resultFactory;
|
|
protected $_objectManager;
|
|
|
|
public function __construct(Context $context, ResultFactory $resultFactory) {
|
|
$this->resultFactory = $resultFactory;
|
|
$this->_objectManager = ObjectManager::getInstance();
|
|
parent::__construct($context);
|
|
}
|
|
|
|
public function execute() {
|
|
$idBanner = $this->getRequest()->getParam("id");
|
|
$blockInstance = $this->_objectManager->get("IpSupply\CustomBanner\Block\CustomBanner");
|
|
|
|
if ($idBanner) {
|
|
$response = $blockInstance->deleteBanner($idBanner); // Value of $response is True or False
|
|
if ($response == True) {
|
|
$this->messageManager->addSuccessMessage(__("Record Delete Successfully."));
|
|
}
|
|
else {
|
|
$this->messageManager->addErrorMessage(__("We can't Delete record, Please try again."));
|
|
}
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
|
$resultRedirect->setPath('*/*/');
|
|
return $resultRedirect;
|
|
}
|
|
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
|
$resultRedirect->setPath('*/*/');
|
|
return $resultRedirect;
|
|
}
|
|
} |