Esempio n. 1
0
 public function testCreate()
 {
     $this->_objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap(array(array('Mage_Backend_Model_Config_Structure_Element_Section', array(), true, 'sectionObject'), array('Mage_Backend_Model_Config_Structure_Element_Group', array(), true, 'groupObject'), array('Mage_Backend_Model_Config_Structure_Element_Field', array(), true, 'fieldObject'))));
     $this->assertEquals('sectionObject', $this->_model->create('section'));
     $this->assertEquals('groupObject', $this->_model->create('group'));
     $this->assertEquals('fieldObject', $this->_model->create('field'));
 }
Esempio n. 2
0
 /**
  * Find element by path parts
  *
  * @param array $pathParts
  * @return Mage_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];
 }