/** * Adds a theme key to identifier for a built-in cache if user-agent theme rule is actual * * @param \Magento\Framework\App\PageCache\Identifier $identifier * @param string $result * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetValue(\Magento\Framework\App\PageCache\Identifier $identifier, $result) { if ($this->generalConfig->isAvailable() && $this->storeSwitcher->getStoreId()) { $result .= $this->storeSwitcher->getStoreId(); } return $result; }
public function testIsAvailable() { $this->appStateHelper->expects($this->once())->method('isFrontendArea')->willReturn(true); $this->scopeConfig->expects($this->any())->method('getStoreValue')->willReturnMap([['tobai_geo_store_switcher/general/white_ips', '127.0.0.1, 10.0.0.1'], ['tobai_geo_store_switcher/general/white_ua', '/^mozilla/i']]); $this->requestHelper->expects($this->once())->method('isCurrentIp')->with(['127.0.0.1', '10.0.0.1'])->willReturn(false); $this->requestHelper->expects($this->once())->method('isCurrentUserAgent')->with('/^mozilla/i')->willReturn(false); $this->scopeConfig->expects($this->once())->method('getFrontendStoreOrBackendValue')->with('tobai_geo_store_switcher/general/active')->willReturn(true); $this->assertTrue($this->configGeneral->isAvailable()); }
/** * {@inheritdoc} */ public function getCurrentStoreId() { $store = $this->getDefaultStoreById(parent::getCurrentStoreId()); $this->generalConfig->setOriginStore($store); if ($this->generalConfig->isAvailable() && !$this->isSwitched) { $this->switchScope(); $this->isSwitched = true; } return parent::getCurrentStoreId(); }
/** * @return bool */ protected function isNeededProcess() { return $this->storeSwitcher->isInitialized() && $this->generalConfig->isAvailable() && $this->geoWebsite->getId() !== false; }
/** * @param \Magento\Store\Model\Group $subject * @param \Magento\Store\Model\Store $store * @return \Magento\Store\Model\Store */ public function afterGetDefaultStore(Group $subject, Store $store) { if ($this->generalConfig->isAvailable() && $this->storeSwitcher->isInitialized()) { $storeId = $this->storeSwitcher->getStoreId(); if ($store->getId() != $storeId && in_array($storeId, $subject->getStoreIds())) { $store = $this->storeRepository->getById($storeId); } } return $store; }