Beispiel #1
0
 /**
  * Start environment emulation of the specified store
  *
  * Function returns information about initial store environment and emulates environment of another store
  *
  * @param integer $storeId
  * @param string $area
  * @param bool $force A true value will ensure that environment is always emulated, regardless of current store
  * @return void
  */
 public function startEnvironmentEmulation($storeId, $area = \Magento\Framework\App\Area::AREA_FRONTEND, $force = false)
 {
     // Only allow a single level of emulation
     if ($this->initialEnvironmentInfo !== null) {
         $this->logger->error(__('Environment emulation nesting is not allowed.'));
         return;
     }
     if ($storeId == $this->_storeManager->getStore()->getStoreId() && !$force) {
         return;
     }
     $this->storeCurrentEnvironmentInfo();
     // emulate inline translations
     $this->inlineTranslation->suspend($this->inlineConfig->isActive($storeId));
     // emulate design
     $storeTheme = $this->_viewDesign->getConfigurationDesignTheme($area, ['store' => $storeId]);
     $this->_viewDesign->setDesignTheme($storeTheme, $area);
     if ($area == \Magento\Framework\App\Area::AREA_FRONTEND) {
         $designChange = $this->_design->loadChange($storeId);
         if ($designChange->getData()) {
             $this->_viewDesign->setDesignTheme($designChange->getDesign(), $area);
         }
     }
     // Current store needs to be changed right before locale change and after design change
     $this->_storeManager->setCurrentStore($storeId);
     // emulate locale
     $newLocaleCode = $this->_scopeConfig->getValue($this->_localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     $this->_localeResolver->setLocale($newLocaleCode);
     $this->_translate->setLocale($newLocaleCode);
     $this->_translate->loadData($area);
     return;
 }
Beispiel #2
0
 /**
  * Check if Inline Translates is allowed
  *
  * @return bool
  */
 public function isAllowed()
 {
     if ($this->isAllowed === null) {
         if (!$this->scope instanceof \Magento\Framework\App\ScopeInterface) {
             $scope = $this->scopeResolver->getScope($this->scope);
         }
         $this->isAllowed = $this->config->isActive($scope) && $this->config->isDevAllowed($scope);
     }
     return $this->state->isEnabled() && $this->isAllowed;
 }
Beispiel #3
0
 /**
  * Emulate inline translation of the specified store
  *
  * Function disables inline translation if $storeId is null
  *
  * @param integer|null $storeId
  * @return boolean initial inline translation state
  */
 protected function _emulateInlineTranslation($storeId = null)
 {
     if (is_null($storeId)) {
         $newTranslateInline = false;
     } else {
         $newTranslateInline = $this->inlineConfig->isActive($storeId);
     }
     $translateInline = $this->inlineTranslation->isEnabled();
     $this->inlineTranslation->suspend($newTranslateInline);
     return $translateInline;
 }