Ejemplo n.º 1
0
 /**
  * Check whether element should be displayed
  *
  * @return bool
  */
 public function isVisible()
 {
     $showInScope = [\Magento\Framework\Store\ScopeInterface::SCOPE_STORE => $this->_hasVisibilityValue('showInStore'), \Magento\Framework\Store\ScopeInterface::SCOPE_WEBSITE => $this->_hasVisibilityValue('showInWebsite'), \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT => $this->_hasVisibilityValue('showInDefault')];
     if ($this->_storeManager->isSingleStoreMode()) {
         $result = !$this->_hasVisibilityValue('hide_in_single_store_mode') && array_sum($showInScope);
         return $result;
     }
     return !empty($showInScope[$this->_scope]);
 }
Ejemplo n.º 2
0
 /**
  * Set correct scope if isSingleStoreMode = true
  *
  * @param \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig
  * @param \Magento\Framework\App\Config\ValueInterface $dataObject
  * @return void
  */
 protected function _checkSingleStoreMode(\Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig, $dataObject)
 {
     $isSingleStoreMode = $this->_storeManager->isSingleStoreMode();
     if (!$isSingleStoreMode) {
         return;
     }
     if (!$fieldConfig->showInDefault()) {
         $websites = $this->_storeManager->getWebsites();
         $singleStoreWebsite = array_shift($websites);
         $dataObject->setScope('websites');
         $dataObject->setWebsiteCode($singleStoreWebsite->getCode());
         $dataObject->setScopeCode($singleStoreWebsite->getCode());
         $dataObject->setScopeId($singleStoreWebsite->getId());
     }
 }