public function testGetChildrenParentIdChildAlias() { $this->_structure->createElement('one', array()); $this->_structure->createElement('two', array()); $this->_structure->createElement('three', array()); $this->_structure->setAsChild('two', 'one'); $this->_structure->setAsChild('three', 'one', 'th'); // getChildren() $this->assertSame(array('two' => 'two', 'three' => 'th'), $this->_structure->getChildren('one')); $this->assertSame(array(), $this->_structure->getChildren('three')); $this->assertSame(array(), $this->_structure->getChildren('nonexisting')); // getParentId() $this->assertEquals('one', $this->_structure->getParentId('two')); $this->assertFalse($this->_structure->getParentId('nonexistent')); // getChildAlias() $this->assertEquals('two', $this->_structure->getChildAlias('one', 'two')); $this->assertEquals('th', $this->_structure->getChildAlias('one', 'three')); $this->assertFalse($this->_structure->getChildAlias('nonexistent', 'child')); $this->assertFalse($this->_structure->getChildAlias('one', 'nonexistent')); }
/** * Get list of child blocks * * Returns associative array of <alias> => <block instance> * * @param string $parentName * @return array */ public function getChildBlocks($parentName) { $blocks = array(); foreach ($this->_structure->getChildren($parentName) as $childName => $alias) { $block = $this->getBlock($childName); if ($block) { $blocks[$alias] = $block; } } return $blocks; }