本文整理汇总了PHP中Mage_Core_Block_Abstract::getParentBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Block_Abstract::getParentBlock方法的具体用法?PHP Mage_Core_Block_Abstract::getParentBlock怎么用?PHP Mage_Core_Block_Abstract::getParentBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Block_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Block_Abstract::getParentBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetParentBlock
public function testSetGetParentBlock()
{
$this->assertEmpty($this->_block->getParentBlock());
$parentBlock = new Mage_Core_Block_Text();
$this->_block->setParentBlock($parentBlock);
$this->assertSame($parentBlock, $this->_block->getParentBlock());
}
示例2: testGetParentBlock
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());
}
示例3: getBlockAlias
/**
* @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();
}
}
示例4: getBlockPath
/**
* 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;
}