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


PHP Layout::createBlock方法代码示例

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


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

示例1: testCreateBlockSuccess

 public function testCreateBlockSuccess()
 {
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->_blockFactoryMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));
     $this->_model->createBlock('type', 'blockname', array());
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $this->_model->getBlock('blockname'));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:7,代码来源:LayoutTest.php

示例2: execute

 /**
  * Categories chooser Action (Ajax request)
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $selected = $this->getRequest()->getParam('selected', '');
     $isAnchorOnly = $this->getRequest()->getParam('is_anchor_only', 0);
     /** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */
     $chooser = $this->layout->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser')->setUseMassaction(true)->setId($this->mathRandom->getUniqueHash('categories'))->setIsAnchorOnly($isAnchorOnly)->setSelectedCategories(explode(',', $selected));
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     return $resultRaw->setContents($chooser->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Categories.php

示例3: testGetChildBlocks

    public function testGetChildBlocks()
    {
        $parentName = 'parent';
        $childrenArray = ['block_name' => 'value1'];
        $this->structureMock->expects($this->once())
            ->method('getChildren')
            ->with($this->equalTo($parentName))
            ->will($this->returnValue($childrenArray));

        $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock')
            ->disableOriginalConstructor()
            ->getMockForAbstractClass();
        $this->structureMock->expects($this->once())
            ->method('createStructuralElement')
            ->with(
                'block_name',
                \Magento\Framework\View\Layout\Element::TYPE_BLOCK,
                'Magento\Framework\View\Element\AbstractBlock'
            )->willReturn('block_name');
        $this->generatorBlockMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));

        $this->assertSame(
            $blockMock,
            $this->model->createBlock('Magento\Framework\View\Element\AbstractBlock', 'block_name', [])
        );
        $this->assertSame(['value1' => $blockMock], $this->model->getChildBlocks($parentName));
    }
开发者ID:nja78,项目名称:magento2,代码行数:27,代码来源:LayoutTest.php

示例4: testToHtmlEmptyWebsiteShareNewCustomer

 /**
  * @magentoConfigFixture customer/account_share/scope 1
  */
 public function testToHtmlEmptyWebsiteShareNewCustomer()
 {
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\View\\Accordion');
     $html = $block->toHtml();
     $this->assertContains('Wishlist - 0 item(s)', $html);
     $this->assertContains('Shopping Cart - 0 item(s)', $html);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:AccordionTest.php

示例5: testRenameElement

 public function testRenameElement()
 {
     $blockName = 'block';
     $expBlockName = 'block_renamed';
     $containerName = 'container';
     $expContainerName = 'container_renamed';
     $block = $this->_layout->createBlock('Magento\\Framework\\View\\Element\\Text', $blockName);
     $this->_layout->addContainer($containerName, 'Container');
     $this->assertEquals($block, $this->_layout->getBlock($blockName));
     $this->_layout->renameElement($blockName, $expBlockName);
     $this->assertEquals($block, $this->_layout->getBlock($expBlockName));
     $this->_layout->hasElement($containerName);
     $this->_layout->renameElement($containerName, $expContainerName);
     $this->_layout->hasElement($expContainerName);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:15,代码来源:LayoutTest.php

示例6: createBlock

 /**
  * {@inheritdoc}
  */
 public function createBlock($type, $name = '', array $arguments = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'createBlock');
     if (!$pluginInfo) {
         return parent::createBlock($type, $name, $arguments);
     } else {
         return $this->___callPlugins('createBlock', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


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