Unassign.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Adminhtml\Order\Status;
  8. use Magento\Framework\App\Action\HttpPostActionInterface;
  9. class Unassign extends \Magento\Sales\Controller\Adminhtml\Order\Status implements HttpPostActionInterface
  10. {
  11. /**
  12. * @return \Magento\Backend\Model\View\Result\Redirect
  13. */
  14. public function execute()
  15. {
  16. $state = $this->getRequest()->getParam('state');
  17. $status = $this->_initStatus();
  18. if ($status) {
  19. try {
  20. $status->unassignState($state);
  21. $this->messageManager->addSuccessMessage(__('You have unassigned the order status.'));
  22. } catch (\Magento\Framework\Exception\LocalizedException $e) {
  23. $this->messageManager->addErrorMessage($e->getMessage());
  24. } catch (\Exception $e) {
  25. $this->messageManager->addExceptionMessage(
  26. $e,
  27. __('Something went wrong while unassigning the order.')
  28. );
  29. }
  30. } else {
  31. $this->messageManager->addErrorMessage(__('We can\'t find this order status.'));
  32. }
  33. /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
  34. $resultRedirect = $this->resultRedirectFactory->create();
  35. return $resultRedirect->setPath('sales/*/');
  36. }
  37. }