本文整理匯總了PHP中Magento\Framework\View\Layout::generateElements方法的典型用法代碼示例。如果您正苦於以下問題:PHP Layout::generateElements方法的具體用法?PHP Layout::generateElements怎麽用?PHP Layout::generateElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Layout
的用法示例。
在下文中一共展示了Layout::generateElements方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testProcessWithExceptions
/**
* @magentoAppIsolation enabled
*/
public function testProcessWithExceptions()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setMode(State::MODE_DEFAULT);
$this->layout->generateElements();
$this->layout->addOutputElement('block.with.broken.constructor');
$this->layout->addOutputElement('block.with.broken.layout');
$this->layout->addOutputElement('block.with.broken.action');
$this->assertEmpty($this->layout->getOutput());
}
示例2: testGenerateElementsWithCache
public function testGenerateElementsWithCache()
{
$layoutCacheId = 'layout_cache_id';
/** @var \Magento\Framework\View\Layout\Element $xml */
$xml = simplexml_load_string('<layout/>', 'Magento\Framework\View\Layout\Element');
$this->model->setXml($xml);
$themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface');
$this->themeResolverMock->expects($this->once())
->method('get')
->willReturn($themeMock);
$this->processorFactoryMock->expects($this->once())
->method('create')
->with(['theme' => $themeMock])
->willReturn($this->processorMock);
$this->processorMock->expects($this->once())
->method('getCacheId')
->willReturn($layoutCacheId);
$readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context')
->disableOriginalConstructor()
->getMock();
$this->cacheMock->expects($this->once())
->method('load')
->with('structure_' . $layoutCacheId)
->willReturn(serialize($readerContextMock));
$this->readerPoolMock->expects($this->never())
->method('interpret');
$this->cacheMock->expects($this->never())
->method('save');
$generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context')
->disableOriginalConstructor()
->getMock();
$this->generatorContextFactoryMock->expects($this->once())
->method('create')
->with(['structure' => $this->structureMock, 'layout' => $this->model])
->willReturn($generatorContextMock);
$this->generatorPoolMock->expects($this->once())
->method('process')
->with($readerContextMock, $generatorContextMock)
->willReturn(true);
$elements = [
'name_1' => ['type' => '', 'parent' => null],
'name_2' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => null],
'name_3' => ['type' => '', 'parent' => 'parent'],
'name_4' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => 'parent'],
];
$this->structureMock->expects($this->once())
->method('exportElements')
->willReturn($elements);
$this->model->generateElements();
}
示例3: generateElements
/**
* {@inheritdoc}
*/
public function generateElements()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'generateElements');
if (!$pluginInfo) {
return parent::generateElements();
} else {
return $this->___callPlugins('generateElements', func_get_args(), $pluginInfo);
}
}
示例4: testIsNonCacheable
public function testIsNonCacheable()
{
$this->_layout->setXml(simplexml_load_file(__DIR__ . '/_files/layout/non_cacheable.xml', 'Magento\\Framework\\View\\Layout\\Element'));
$this->_layout->generateElements();
$this->assertFalse($this->_layout->isCacheable());
}