/** * Apply persistent data * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute($observer) { if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) { return $this; } /** @var \Magento\Persistent\Model\Persistent\Config $persistentConfig */ $persistentConfig = $this->_persistentConfigFactory->create(); $persistentConfig->setConfigFilePath($this->_persistentData->getPersistentConfigFilePath())->fire(); return $this; }
/** * Apply persistent data to specific block * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { if (!$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) { return $this; } /** @var $block \Magento\Framework\View\Element\AbstractBlock */ $block = $observer->getEvent()->getBlock(); if (!$block) { return $this; } $configFilePath = $observer->getEvent()->getConfigFilePath(); if (!$configFilePath) { $configFilePath = $this->_persistentData->getPersistentConfigFilePath(); } /** @var $persistentConfig \Magento\Persistent\Model\Persistent\Config */ $persistentConfig = $this->_persistentConfigFactory->create(); $persistentConfig->setConfigFilePath($configFilePath); foreach ($persistentConfig->getBlockConfigInfo(get_class($block)) as $persistentConfigInfo) { $persistentConfig->fireOne($persistentConfigInfo, $block); } return $this; }