Delete.php 787 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
  8. class Delete extends \Magento\Widget\Controller\Adminhtml\Widget\Instance
  9. {
  10. /**
  11. * Delete Action
  12. *
  13. * @return void
  14. */
  15. public function execute()
  16. {
  17. $widgetInstance = $this->_initWidgetInstance();
  18. if ($widgetInstance) {
  19. try {
  20. $widgetInstance->delete();
  21. $this->messageManager->addSuccess(__('The widget instance has been deleted.'));
  22. } catch (\Exception $e) {
  23. $this->messageManager->addError($e->getMessage());
  24. }
  25. }
  26. $this->_redirect('adminhtml/*/');
  27. return;
  28. }
  29. }