Exemplo n.º 1
0
 public function testCreate()
 {
     $this->_objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap([['Magento\\Backend\\Model\\Config\\Structure\\Element\\Section', [], 'sectionObject'], ['Magento\\Backend\\Model\\Config\\Structure\\Element\\Group', [], 'groupObject'], ['Magento\\Backend\\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'));
 }
Exemplo n.º 2
0
 /**
  * Find element by path parts
  *
  * @param string[] $pathParts
  * @return \Magento\Backend\Model\Config\Structure\ElementInterface|null
  */
 public function getElementByPathParts(array $pathParts)
 {
     $path = implode('_', $pathParts);
     if (isset($this->_elements[$path])) {
         return $this->_elements[$path];
     }
     $children = $this->_data['sections'];
     $child = array();
     foreach ($pathParts as $pathPart) {
         if (array_key_exists($pathPart, $children)) {
             $child = $children[$pathPart];
             $children = array_key_exists('children', $child) ? $child['children'] : array();
         } 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];
 }