コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 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());
 }
コード例 #3
0
 /**
  * {@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();
 }
コード例 #4
0
 /**
  * @return bool
  */
 protected function isNeededProcess()
 {
     return $this->storeSwitcher->isInitialized() && $this->generalConfig->isAvailable() && $this->geoWebsite->getId() !== false;
 }
コード例 #5
-1
 /**
  * @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;
 }