Delete.php 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Backend\Controller\Adminhtml\System\Design;
  8. class Delete extends \Magento\Backend\Controller\Adminhtml\System\Design
  9. {
  10. /**
  11. * @return \Magento\Backend\Model\View\Result\Redirect
  12. */
  13. public function execute()
  14. {
  15. $id = $this->getRequest()->getParam('id');
  16. if ($id) {
  17. $design = $this->_objectManager->create(\Magento\Framework\App\DesignInterface::class)->load($id);
  18. try {
  19. $design->delete();
  20. $this->messageManager->addSuccessMessage(__('You deleted the design change.'));
  21. } catch (\Magento\Framework\Exception\LocalizedException $e) {
  22. $this->messageManager->addErrorMessage($e->getMessage());
  23. } catch (\Exception $e) {
  24. $this->messageManager->addExceptionMessage($e, __("You can't delete the design change."));
  25. }
  26. }
  27. /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
  28. $resultRedirect = $this->resultRedirectFactory->create();
  29. return $resultRedirect->setPath('adminhtml/*/');
  30. }
  31. }