当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Layout::getChildBlocks方法代码示例

本文整理汇总了PHP中Mage_Core_Model_Layout::getChildBlocks方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Layout::getChildBlocks方法的具体用法?PHP Mage_Core_Model_Layout::getChildBlocks怎么用?PHP Mage_Core_Model_Layout::getChildBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Model_Layout的用法示例。


在下文中一共展示了Mage_Core_Model_Layout::getChildBlocks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetChildBlocks

 public function testGetChildBlocks()
 {
     $this->_layout->addContainer('parent', 'Parent');
     $block1 = $this->_layout->addBlock('Mage_Core_Block_Text', 'block1', 'parent');
     $this->_layout->addContainer('container', 'Container', array(), 'parent');
     $block2 = $this->_layout->addBlock('Mage_Core_Block_Template', 'block2', 'parent');
     $this->assertSame(array('block1' => $block1, 'block2' => $block2), $this->_layout->getChildBlocks('parent'));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:8,代码来源:LayoutTest.php

示例2: testLayoutDirectives

 public function testLayoutDirectives()
 {
     /**
      * Test correct move
      */
     $layout = new Mage_Core_Model_Layout();
     $layout->getUpdate()->load(array('layout_test_handle_move'));
     $layout->generateXml()->generateElements();
     $this->assertEquals('container2', $layout->getParentName('container1'));
     $this->assertEquals('container1', $layout->getParentName('no.name2'));
     $this->assertEquals('block_container', $layout->getParentName('no_name3'));
     // verify `after` attribute
     $this->assertEquals('block_container', $layout->getParentName('no_name'));
     $childrenOrderArray = array_keys($layout->getChildBlocks($layout->getParentName('no_name')));
     $positionAfter = array_search('child_block1', $childrenOrderArray);
     $positionToVerify = array_search('no_name', $childrenOrderArray);
     $this->assertEquals($positionAfter, --$positionToVerify);
     // verify `before` attribute
     $this->assertEquals('block_container', $layout->getParentName('no_name4'));
     $childrenOrderArray = array_keys($layout->getChildBlocks($layout->getParentName('no_name4')));
     $positionBefore = array_search('child_block2', $childrenOrderArray);
     $positionToVerify = array_search('no_name4', $childrenOrderArray);
     $this->assertEquals($positionBefore, ++$positionToVerify);
     /**
      * Test move with the same alias
      */
     $layout = new Mage_Core_Model_Layout();
     $layout->getUpdate()->load(array('layout_test_handle_move_the_same_alias'));
     $layout->generateXml()->generateElements();
     $this->assertEquals('container1', $layout->getParentName('no_name3'));
     /**
      * Test move with a new alias
      */
     $layout = new Mage_Core_Model_Layout();
     $layout->getUpdate()->load(array('layout_test_handle_move_new_alias'));
     $layout->generateXml()->generateElements();
     $this->assertEquals('new_alias', $layout->getElementAlias('no_name3'));
     /**
      * Test layout action with anonymous parent block
      */
     $layout = new Mage_Core_Model_Layout();
     $layout->getUpdate()->load(array('layout_test_handle_action_for_anonymous_parent_block'));
     $layout->generateXml()->generateElements();
     $this->assertEquals('schedule_block', $layout->getParentName('test.block.insert'));
     $this->assertEquals('schedule_block_1', $layout->getParentName('test.block.append'));
     /**
      * Test layout remove directive
      */
     $layout = new Mage_Core_Model_Layout();
     $layout->getUpdate()->load(array('layout_test_handle_remove'));
     $layout->generateXml()->generateElements();
     $this->assertFalse($layout->getBlock('no_name2'));
     $this->assertFalse($layout->getBlock('child_block1'));
     $this->assertTrue($layout->isBlock('child_block2'));
 }
开发者ID:nayanchamp,项目名称:magento2,代码行数:55,代码来源:LayoutTest.php


注:本文中的Mage_Core_Model_Layout::getChildBlocks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。