65 private $checkoutPagePath =
'checkout';
78 \
Magento\Persistent\Helper\Data $persistentData,
80 \
Magento\Framework\Event\ManagerInterface $eventManager,
81 \
Magento\Customer\Model\Session $customerSession,
82 \
Magento\Checkout\Model\Session $checkoutSession,
83 \
Magento\Framework\
App\RequestInterface $request
87 $this->_customerSession = $customerSession;
88 $this->_checkoutSession = $checkoutSession;
89 $this->_eventManager = $eventManager;
90 $this->_persistentData = $persistentData;
102 if (!$this->_persistentData->canProcess(
$observer)) {
106 if ($this->_persistentData->isEnabled() &&
107 !$this->_persistentSession->isPersistent() &&
108 !$this->_customerSession->isLoggedIn() &&
109 $this->_checkoutSession->getQuoteId() &&
110 !$this->isRequestFromCheckoutPage($this->request)
113 $this->_eventManager->dispatch(
'persistent_session_expired');
114 $this->quoteManager->expire();
115 $this->_customerSession->setCustomerId(
null)->setCustomerGroupId(
null);
125 private function isRequestFromCheckoutPage(\
Magento\Framework\
App\RequestInterface $request): bool
127 $requestUri = (string)
$request->getRequestUri();
128 $refererUri = (string)
$request->getServer(
'HTTP_REFERER');
132 false !== strpos($requestUri, $this->checkoutPagePath) ||
133 false !== strpos($refererUri, $this->checkoutPagePath)
136 return $isCheckoutPage;
execute(\Magento\Framework\Event\Observer $observer)
__construct(\Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Helper\Data $persistentData, \Magento\Persistent\Model\QuoteManager $quoteManager, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\App\RequestInterface $request)