Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractAction.php
Go to the documentation of this file.
1 <?php
8 
16 
20 abstract class AbstractAction extends Action
21 {
25  protected $config;
26 
30  protected $checkoutSession;
31 
39  public function __construct(
40  Context $context,
43  ) {
44  parent::__construct($context);
45  $this->config = $config;
46  $this->checkoutSession = $checkoutSession;
47  }
48 
55  {
56  if (!$this->config->isActive() || !$this->config->isDisplayShoppingCart()) {
57  $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
58 
60  $resultRedirect = $this->resultRedirectFactory->create();
61  $resultRedirect->setPath('noRoute');
62 
63  return $resultRedirect;
64  }
65 
66  return parent::dispatch($request);
67  }
68 
74  protected function validateQuote($quote)
75  {
76  if (!$quote || !$quote->getItemsCount()) {
77  throw new \InvalidArgumentException(__('Checkout failed to initialize. Verify and try again.'));
78  }
79  }
80 }
$quote
__()
Definition: __.php:13
__construct(Context $context, Config $config, Session $checkoutSession)
dispatch(RequestInterface $request)
Definition: Action.php:92