58 $this->_formKeyValidator = $formKeyValidator;
59 $this->_scopeConfig = $scopeConfig;
60 $this->_checkoutSession = $checkoutSession;
63 parent::__construct($context);
73 protected function _goBack($backUrl =
null)
75 $resultRedirect = $this->resultRedirectFactory->create();
78 $resultRedirect->setUrl($backUrl);
81 return $resultRedirect;
90 protected function _isInternalUrl(
$url)
92 if (strpos(
$url,
'http') ===
false) {
100 $store = $this->_storeManager->getStore();
101 $unsecure = strpos(
$url,
$store->getBaseUrl()) === 0;
102 $secure = strpos(
$url,
$store->getBaseUrl(\
Magento\Framework\UrlInterface::URL_TYPE_LINK,
true)) === 0;
103 return $unsecure || $secure;
114 $returnUrl = $this->
getRequest()->getParam(
'return_url');
115 if ($returnUrl && $this->_isInternalUrl($returnUrl)) {
116 $this->messageManager->getMessages()->clear();
120 if ($this->shouldRedirectToCart() || $this->
getRequest()->getParam(
'in_cart')) {
121 if ($this->
getRequest()->getActionName() ==
'add' && !$this->
getRequest()->getParam(
'in_cart')) {
122 $this->_checkoutSession->setContinueShoppingUrl($this->
_redirect->getRefererUrl());
124 return $this->_url->getUrl(
'checkout/cart');
135 private function shouldRedirectToCart()
137 return $this->_scopeConfig->isSetFlag(
138 'checkout/cart/redirect_to_cart',
getBackUrl($defaultUrl=null)
_redirect($path, $arguments=[])
__construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, CustomerCart $cart)