public function testGetAttribute()
 {
     $this->_model->setData(['id' => 'elementId', 'label' => 'Element Label', 'someAttribute' => 'Some attribute value'], 'someScope');
     $this->assertEquals('elementId', $this->_model->getAttribute('id'));
     $this->assertEquals('Element Label', $this->_model->getAttribute('label'));
     $this->assertEquals('Some attribute value', $this->_model->getAttribute('someAttribute'));
     $this->assertNull($this->_model->getAttribute('nonexistingAttribute'));
 }
Пример #2
0
 /**
  * Check a configuration element visibility
  *
  * @param \Magento\Config\Model\Config\Structure\AbstractElement $element The config composite element
  * @param string                                                 $scope   The element scope
  *
  * @return bool
  */
 public function isVisible(\Magento\Config\Model\Config\Structure\AbstractElement $element, $scope)
 {
     if ($element->getAttribute('if_module_enabled') && !$this->moduleManager->isOutputEnabled($element->getAttribute('if_module_enabled'))) {
         return false;
     }
     $showInScope = [ContainerScopeInterface::SCOPE_DEFAULT => $element->getAttribute('showInDefault'), ContainerScopeInterface::SCOPE_CONTAINERS => $element->getAttribute('showInContainer'), ContainerScopeInterface::SCOPE_STORE_CONTAINERS => $element->getAttribute('showInStore')];
     if ($this->storeManager->isSingleStoreMode()) {
         $result = !$element->getAttribute('hide_in_single_store_mode') && array_sum($showInScope);
         return $result;
     }
     return !empty($showInScope[$scope]);
 }