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


PHP Layout::setXml方法代碼示例

本文整理匯總了PHP中Magento\Framework\View\Layout::setXml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Layout::setXml方法的具體用法?PHP Layout::setXml怎麽用?PHP Layout::setXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\View\Layout的用法示例。


在下文中一共展示了Layout::setXml方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $layoutFactory = $objectManager->get('Magento\\Framework\\View\\LayoutFactory');
     $this->layout = $layoutFactory->create();
     $layoutElement = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/layout_with_exceptions/layout.xml', 0, true);
     $this->layout->setXml($layoutElement);
     $objectManager->get('Magento\\Framework\\App\\Cache\\Type\\Layout')->clean();
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:9,代碼來源: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: 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

示例4: testIsCacheable

 /**
  * @param string $xmlString
  * @param bool $result
  * @dataProvider isCacheableDataProvider
  */
 public function testIsCacheable($xmlString, $result)
 {
     $xml = simplexml_load_string($xmlString, 'Magento\\Framework\\View\\Layout\\Element');
     $this->assertSame($this->model, $this->model->setXml($xml));
     $this->assertSame($result, $this->model->isCacheable());
 }
開發者ID:ViniciusAugusto,項目名稱:magento2,代碼行數:11,代碼來源:LayoutTest.php

示例5: setXml

 /**
  * {@inheritdoc}
  */
 public function setXml(\Magento\Framework\Simplexml\Element $node)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setXml');
     if (!$pluginInfo) {
         return parent::setXml($node);
     } else {
         return $this->___callPlugins('setXml', func_get_args(), $pluginInfo);
     }
 }
開發者ID:HaonanXu,項目名稱:der-snack-backup,代碼行數:12,代碼來源:Interceptor.php


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