Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Success.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10 
11 class Success extends \Magento\Checkout\Controller\Onepage implements HttpGetActionInterface
12 {
18  public function execute()
19  {
20  $session = $this->getOnepage()->getCheckout();
21  if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
22  return $this->resultRedirectFactory->create()->setPath('checkout/cart');
23  }
24  $session->clearQuote();
25  //@todo: Refactor it to match CQRS
26  $resultPage = $this->resultPageFactory->create();
27  $this->_eventManager->dispatch(
28  'checkout_onepage_controller_success_action',
29  ['order_ids' => [$session->getLastOrderId()]]
30  );
31  return $resultPage;
32  }
33 }