Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ApplyPersistentDataObserver.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
18  protected $_customerSession;
19 
26 
32  protected $_persistentSession = null;
33 
39  protected $_persistentData = null;
40 
47  public function __construct(
48  \Magento\Persistent\Helper\Session $persistentSession,
49  \Magento\Persistent\Helper\Data $persistentData,
50  \Magento\Customer\Model\Session $customerSession,
51  \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory
52  ) {
53  $this->_persistentSession = $persistentSession;
54  $this->_persistentData = $persistentData;
55  $this->_customerSession = $customerSession;
56  $this->_persistentConfigFactory = $persistentConfigFactory;
57  }
58 
65  public function execute(\Magento\Framework\Event\Observer $observer)
66  {
67  if (!$this->_persistentData->canProcess($observer)
68  || !$this->_persistentSession->isPersistent()
69  || $this->_customerSession->isLoggedIn()
70  ) {
71  return $this;
72  }
74  $persistentConfig = $this->_persistentConfigFactory->create();
75  $persistentConfig->setConfigFilePath($this->_persistentData->getPersistentConfigFilePath())->fire();
76  return $this;
77  }
78 }
$persistentSession
Definition: persistent.php:11
__construct(\Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Helper\Data $persistentData, \Magento\Customer\Model\Session $customerSession, \Magento\Persistent\Model\Persistent\ConfigFactory $persistentConfigFactory)