本文整理匯總了PHP中Magento\Framework\View\LayoutInterface::addToParentGroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP LayoutInterface::addToParentGroup方法的具體用法?PHP LayoutInterface::addToParentGroup怎麽用?PHP LayoutInterface::addToParentGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\LayoutInterface
的用法示例。
在下文中一共展示了LayoutInterface::addToParentGroup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testToHtmlPropagatesUrl
public function testToHtmlPropagatesUrl()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
$this->_block->setShouldPrepareInfoTabs(true);
$childOne = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child1', 'block');
$this->_layout->addToParentGroup('child1', 'info_tabs');
$childTwo = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child2', 'block');
$this->_layout->addToParentGroup('child2', 'info_tabs');
$this->assertEmpty($childOne->getViewUrl());
$this->assertEmpty($childTwo->getViewUrl());
$this->_block->toHtml();
$this->assertNotEmpty($childOne->getViewUrl());
$this->assertNotEmpty($childTwo->getViewUrl());
}
示例2: testAddToParentGroup
/**
* @magentoAppIsolation enabled
* @covers \Magento\Framework\View\Element\AbstractBlock::getGroupChildNames
* @covers \Magento\Framework\View\Layout::addToParentGroup
*/
public function testAddToParentGroup()
{
$parent = $this->_createBlockWithLayout('parent', 'parent');
$block1 = $this->_createBlockWithLayout('block1', 'block1');
$block2 = $this->_createBlockWithLayout('block2', 'block2');
$parent->setChild('block1', $block1)->setChild('block2', $block2);
$this->_layout->addToParentGroup('block1', 'group');
$this->_layout->addToParentGroup('block2', 'group');
$group = $parent->getGroupChildNames('group');
$this->assertContains('block1', $group);
$this->assertContains('block2', $group);
$this->assertSame($group[0], 'block1');
$this->assertSame($group[1], 'block2');
}