public function testCreate()
 {
     $this->_objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap([['Magento\\Config\\Model\\Config\\Structure\\Element\\Section', [], 'sectionObject'], ['Magento\\Config\\Model\\Config\\Structure\\Element\\Group', [], 'groupObject'], ['Magento\\Config\\Model\\Config\\Structure\\Element\\Field', [], 'fieldObject']]));
     $this->assertEquals('sectionObject', $this->_model->create('section'));
     $this->assertEquals('groupObject', $this->_model->create('group'));
     $this->assertEquals('fieldObject', $this->_model->create('field'));
 }
예제 #2
0
 /**
  * Find element by path parts
  *
  * @param string[] $pathParts
  * @return \Magento\Config\Model\Config\Structure\ElementInterface|null
  */
 public function getElementByPathParts(array $pathParts)
 {
     $path = implode('_', $pathParts);
     if (isset($this->_elements[$path])) {
         return $this->_elements[$path];
     }
     $children = [];
     if ($this->_data) {
         $children = $this->_data['sections'];
     }
     $child = [];
     foreach ($pathParts as $pathPart) {
         if ($children && array_key_exists($pathPart, $children)) {
             $child = $children[$pathPart];
             $children = array_key_exists('children', $child) ? $child['children'] : [];
         } else {
             $child = $this->_createEmptyElement($pathParts);
             break;
         }
     }
     $this->_elements[$path] = $this->_flyweightFactory->create($child['_elementType']);
     $this->_elements[$path]->setData($child, $this->_scopeDefiner->getScope());
     return $this->_elements[$path];
 }
 /**
  * @param array $groupData
  * @param string $scope
  * @return \Magento\Config\Model\Config\Structure\Element\Group
  */
 protected function createGroup(array $groupData, $scope = 'default')
 {
     $group = $this->flyweightFactory->create('group');
     $group->setData($groupData, $scope);
     return $group;
 }