當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Layout::generateElements方法代碼示例

本文整理匯總了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());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:12,代碼來源:LayoutTestWithExceptions.php

示例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();
    }
開發者ID:nja78,項目名稱:magento2,代碼行數:60,代碼來源:LayoutTest.php

示例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);
     }
 }
開發者ID:HaonanXu,項目名稱:der-snack-backup,代碼行數:12,代碼來源:Interceptor.php

示例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());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:6,代碼來源:LayoutTest.php


注:本文中的Magento\Framework\View\Layout::generateElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。