Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetRememberMeCheckedStatusObserver.php
Go to the documentation of this file.
1 <?php
7 
9 
11 
16 {
23 
29  protected $_persistentData = null;
30 
36  protected $_checkoutSession;
37 
45  public function __construct(
46  \Magento\Persistent\Helper\Data $persistentData,
47  \Magento\Persistent\Helper\Session $persistentSession,
48  \Magento\Checkout\Model\Session $checkoutSession
49  ) {
50  $this->_persistentData = $persistentData;
51  $this->_persistentSession = $persistentSession;
52  $this->_checkoutSession = $checkoutSession;
53  }
54 
61  public function execute(Observer $observer)
62  {
63  if (!$this->_persistentData->canProcess($observer)
64  || !$this->_persistentData->isEnabled()
65  || !$this->_persistentData->isRememberMeEnabled()
66  ) {
67  return;
68  }
69 
71  $request = $observer->getEvent()->getRequest();
72  if ($request) {
73  $rememberMeCheckbox = $request->getPost('persistent_remember_me');
74  $this->_persistentSession->setRememberMeChecked((bool)$rememberMeCheckbox);
75  if ($request->getFullActionName() == 'checkout_onepage_saveBilling' ||
76  $request->getFullActionName() == 'customer_account_createpost'
77  ) {
78  $this->_checkoutSession->setRememberMeChecked((bool)$rememberMeCheckbox);
79  }
80  }
81  }
82 }
$persistentSession
Definition: persistent.php:11
__construct(\Magento\Persistent\Helper\Data $persistentData, \Magento\Persistent\Helper\Session $persistentSession, \Magento\Checkout\Model\Session $checkoutSession)