File: /home/petsclubcc/magento/vendor/magento/module-cms/Controller/Adminhtml/Block/Delete.php
<?php
/**
*
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Controller\Adminhtml\Block;
class Delete extends \Magento\Cms\Controller\Adminhtml\Block
{
/**
* 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('block_id');
if ($id) {
try {
// init model and delete
$model = $this->_objectManager->create('Magento\Cms\Model\Block');
$model->load($id);
$model->delete();
// display success message
$this->messageManager->addSuccess(__('You deleted the block.'));
// go to grid
return $resultRedirect->setPath('*/*/');
} catch (\Exception $e) {
// display error message
$this->messageManager->addError($e->getMessage());
// go back to edit form
return $resultRedirect->setPath('*/*/edit', ['block_id' => $id]);
}
}
// display error message
$this->messageManager->addError(__('We can\'t find a block to delete.'));
// go to grid
return $resultRedirect->setPath('*/*/');
}
}