public function testSetGetParentBlock() { $this->assertEmpty($this->_block->getParentBlock()); $parentBlock = new Mage_Core_Block_Text(); $this->_block->setParentBlock($parentBlock); $this->assertSame($parentBlock, $this->_block->getParentBlock()); }
public function testGetParentBlock() { // Without layout $this->assertFalse($this->_block->getParentBlock()); // Need to create blocks through layout $parentBlock = $this->_createBlockWithLayout('block1', 'block1', 'Mage_Core_Block_Text'); $childBlock = $this->_createBlockWithLayout('block2', 'block2'); $this->assertEmpty($childBlock->getParentBlock()); $parentBlock->setChild('block2', $childBlock); $this->assertSame($parentBlock, $childBlock->getParentBlock()); }
/** * @param Mage_Core_Block_Abstract $block */ public function getBlockAlias($block) { if (($parent = $block->getParentBlock()) && $this->startsWith($block->getNameInLayout(), $parent->getNameInLayout() . '.')) { return substr($block->getNameInLayout(), strlen($parent->getNameInLayout() . '.')); } else { return $block->getNameInLayout(); } }
/** * Get path information of a block * * @param Mage_Core_Block_Abstract $block * @return string * @author Fabrizio Branca * @since 2011-01-24 */ public function getBlockPath(Mage_Core_Block_Abstract $block) { $blockPath = array(); $step = $block->getParentBlock(); $i = 0; while ($i++ < 20 && $step instanceof Mage_Core_Block_Abstract) { $blockPath[] = $this->getBlockInfo($step, false); $step = $step->getParentBlock(); } return $blockPath; }