Skip to content

Commit c90c2a3

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-36105' into MAGETWO-36610
2 parents 201239d + 41cb6d6 commit c90c2a3

File tree

4 files changed

+78
-66
lines changed

4 files changed

+78
-66
lines changed

app/code/Magento/Persistent/Controller/Index.php

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,69 @@
55
*/
66
namespace Magento\Persistent\Controller;
77

8+
use Magento\Framework\App\Action\Action;
9+
use Magento\Framework\App\Action\Context;
10+
use Magento\Persistent\Model\QuoteManager;
11+
use Magento\Checkout\Model\Session as CheckoutSession;
12+
use Magento\Customer\Model\Session as CustomerSession;
13+
use Magento\Persistent\Helper\Session as SessionHelper;
14+
815
/**
916
* Persistent front controller
1017
*/
11-
class Index extends \Magento\Framework\App\Action\Action
18+
class Index extends Action
1219
{
1320
/**
14-
* Whether clear checkout session when logout
21+
* Persistent observer
1522
*
16-
* @var bool
23+
* @var \Magento\Persistent\Model\Observer
1724
*/
18-
protected $_clearCheckoutSession = true;
25+
protected $quoteManager;
26+
27+
/**
28+
* Checkout session
29+
*
30+
* @var \Magento\Checkout\Model\Session
31+
*/
32+
protected $checkoutSession;
1933

2034
/**
2135
* Customer session
2236
*
2337
* @var \Magento\Customer\Model\Session
2438
*/
25-
protected $_customerSession;
39+
protected $customerSession;
2640

2741
/**
28-
* Checkout session
29-
*
30-
* @var \Magento\Checkout\Model\Session
42+
* @var \Magento\Persistent\Helper\Session
3143
*/
32-
protected $_checkoutSession;
44+
protected $sessionHelper;
3345

3446
/**
35-
* Persistent observer
47+
* Whether clear checkout session when logout
3648
*
37-
* @var \Magento\Persistent\Model\Observer
49+
* @var bool
3850
*/
39-
protected $quoteManager;
51+
protected $clearCheckoutSession = true;
4052

4153
/**
4254
* @param \Magento\Framework\App\Action\Context $context
4355
* @param \Magento\Persistent\Model\QuoteManager $quoteManager
4456
* @param \Magento\Checkout\Model\Session $checkoutSession
4557
* @param \Magento\Customer\Model\Session $customerSession
58+
* @param \Magento\Persistent\Helper\Session $sessionHelper
4659
*/
4760
public function __construct(
48-
\Magento\Framework\App\Action\Context $context,
49-
\Magento\Persistent\Model\QuoteManager $quoteManager,
50-
\Magento\Checkout\Model\Session $checkoutSession,
51-
\Magento\Customer\Model\Session $customerSession
61+
Context $context,
62+
QuoteManager $quoteManager,
63+
CheckoutSession $checkoutSession,
64+
CustomerSession $customerSession,
65+
SessionHelper $sessionHelper
5266
) {
5367
$this->quoteManager = $quoteManager;
54-
$this->_checkoutSession = $checkoutSession;
55-
$this->_customerSession = $customerSession;
68+
$this->checkoutSession = $checkoutSession;
69+
$this->customerSession = $customerSession;
70+
$this->sessionHelper = $sessionHelper;
5671
parent::__construct($context);
5772
}
5873

@@ -64,17 +79,7 @@ public function __construct(
6479
*/
6580
public function setClearCheckoutSession($clear = true)
6681
{
67-
$this->_clearCheckoutSession = $clear;
82+
$this->clearCheckoutSession = $clear;
6883
return $this;
6984
}
70-
71-
/**
72-
* Retrieve 'persistent session' helper instance
73-
*
74-
* @return \Magento\Persistent\Helper\Session
75-
*/
76-
protected function _getHelper()
77-
{
78-
return $this->_objectManager->get('Magento\Persistent\Helper\Session');
79-
}
8085
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Persistent\Controller\Index;
87

9-
class ExpressCheckout extends \Magento\Persistent\Controller\Index
8+
use Magento\Persistent\Controller\Index;
9+
use Magento\Framework\Controller\ResultFactory;
10+
11+
class ExpressCheckout extends Index
1012
{
1113
/**
1214
* Add appropriate session message and redirect to shopping cart
1315
*
14-
* @return void
16+
* @return \Magento\Framework\Controller\Result\Redirect
1517
*/
1618
public function execute()
1719
{
1820
$this->messageManager->addNotice(__('Your shopping cart has been updated with new prices.'));
19-
$this->_redirect('checkout/cart');
21+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
22+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
23+
$resultRedirect->setPath('checkout/cart');
24+
return $resultRedirect;
2025
}
2126
}
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Persistent\Controller\Index;
87

9-
class SaveMethod extends \Magento\Persistent\Controller\Index
10-
{
11-
/**
12-
* @var \Magento\Persistent\Model\QuoteManager
13-
*/
14-
protected $quoteManager;
8+
use Magento\Persistent\Controller\Index;
9+
use Magento\Framework\Controller\ResultFactory;
1510

11+
class SaveMethod extends Index
12+
{
1613
/**
1714
* Save onepage checkout method to be register
1815
*
19-
* @return void
16+
* @return \Magento\Framework\Controller\Result\Redirect
2017
*/
2118
public function execute()
2219
{
23-
if ($this->_getHelper()->isPersistent()) {
24-
$this->_getHelper()->getSession()->removePersistentCookie();
25-
if (!$this->_customerSession->isLoggedIn()) {
26-
$this->_customerSession->setCustomerId(null)->setCustomerGroupId(null);
20+
if ($this->sessionHelper->isPersistent()) {
21+
$this->sessionHelper->getSession()->removePersistentCookie();
22+
if (!$this->customerSession->isLoggedIn()) {
23+
$this->customerSession->setCustomerId(null)->setCustomerGroupId(null);
2724
}
28-
2925
$this->quoteManager->setGuest();
3026
}
31-
3227
$checkoutUrl = $this->_redirect->getRefererUrl();
33-
$this->getResponse()->setRedirect($checkoutUrl . (strpos($checkoutUrl, '?') ? '&' : '?') . 'register');
28+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
29+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
30+
$resultRedirect->setUrl($checkoutUrl . (strpos($checkoutUrl, '?') ? '&' : '?') . 'register');
31+
return $resultRedirect;
3432
}
3533
}
Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Persistent\Controller\Index;
87

9-
class UnsetCookie extends \Magento\Persistent\Controller\Index
8+
use Magento\Persistent\Controller\Index;
9+
use Magento\Framework\Controller\ResultFactory;
10+
11+
class UnsetCookie extends Index
1012
{
1113
/**
12-
* Revert all persistent data
14+
* Unset persistent cookie action
1315
*
14-
* @return $this
16+
* @return \Magento\Framework\Controller\Result\Redirect
1517
*/
16-
protected function _cleanup()
18+
public function execute()
1719
{
18-
$this->_eventManager->dispatch('persistent_session_expired');
19-
$this->_customerSession->setCustomerId(null)->setCustomerGroupId(null);
20-
if ($this->_clearCheckoutSession) {
21-
$this->_checkoutSession->clearStorage();
20+
if ($this->sessionHelper->isPersistent()) {
21+
$this->cleanup();
2222
}
23-
$this->_getHelper()->getSession()->removePersistentCookie();
24-
return $this;
23+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
24+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
25+
$resultRedirect->setPath('customer/account/login');
26+
return $resultRedirect;
2527
}
2628

2729
/**
28-
* Unset persistent cookie action
30+
* Revert all persistent data
2931
*
30-
* @return void
32+
* @return $this
3133
*/
32-
public function execute()
34+
protected function cleanup()
3335
{
34-
if ($this->_getHelper()->isPersistent()) {
35-
$this->_cleanup();
36+
$this->_eventManager->dispatch('persistent_session_expired');
37+
$this->customerSession->setCustomerId(null)->setCustomerGroupId(null);
38+
if ($this->clearCheckoutSession) {
39+
$this->checkoutSession->clearStorage();
3640
}
37-
$this->_redirect('customer/account/login');
38-
return;
41+
$this->sessionHelper->getSession()->removePersistentCookie();
42+
return $this;
3943
}
4044
}

0 commit comments

Comments
 (0)