public function testSetGetNameInLayout() { // basic setting/getting $this->assertEmpty($this->_block->getNameInLayout()); $name = uniqid('name'); $this->_block->setNameInLayout($name); $this->assertEquals($name, $this->_block->getNameInLayout()); // setting second time, along with the layout $layout = Mage::app()->getLayout(); $layout->createBlock('Mage_Core_Block_Template', $name); $block = $layout->getBlock($name); $this->assertInstanceOf('Mage_Core_Block_Abstract', $block); $block->setNameInLayout($name); $this->assertInstanceOf('Mage_Core_Block_Abstract', $layout->getBlock($name)); }
/** * Set child block * * @param string $alias * @param Mage_Core_Block_Abstract|string $block * @return Mage_Core_Block_Abstract */ public function setChild($alias, $block) { $layout = $this->getLayout(); if (!$layout) { return $this; } $thisName = $this->getNameInLayout(); if ($layout->getChildName($thisName, $alias)) { $this->unsetChild($alias); } if ($block instanceof self) { if ($block->getIsAnonymous()) { $block->setNameInLayout($this->getNameInLayout() . '.' . $alias); } $block = $block->getNameInLayout(); } $layout->setChild($thisName, $block, $alias); return $this; }