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


PHP Layout::getBlock方法代码示例

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


在下文中一共展示了Layout::getBlock方法的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: testCreateBlockSuccess

 public function testCreateBlockSuccess()
 {
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->structureMock->expects($this->once())->method('createStructuralElement')->with('blockname', \Magento\Framework\View\Layout\Element::TYPE_BLOCK, 'type')->willReturn('blockname');
     $this->generatorBlockMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));
     $this->model->createBlock('type', 'blockname', []);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $this->model->getBlock('blockname'));
     $this->assertFalse($this->model->getBlock('not_exist'));
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:9,代码来源:LayoutTest.php

示例3: testGetBlock

 public function testGetBlock()
 {
     $this->assertFalse($this->_layout->getBlock('test'));
     $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\Layout')->createBlock('Magento\\Framework\\View\\Element\\Text');
     $this->_layout->setBlock('test', $block);
     $this->assertSame($block, $this->_layout->getBlock('test'));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:LayoutTest.php

示例4: getBlockExtras

 public function getBlockExtras($name, $data)
 {
     if (isset($data['type'])) {
         $extras[] = $data['type'];
     }
     $block = $this->_layout->getBlock($name);
     if ($block) {
         if ($block instanceof \Magento\Cms\Block\Block) {
             $extras[] = $block->getBlockId();
         }
         if ($block instanceof \Magento\Cms\Block\Page) {
             $extras[] = $block->getPage()->getIdentifier();
         }
         if ($block instanceof \Magento\Framework\View\Element\Template) {
             $extras[] = $block->getTemplate();
         }
         $extras[] = $block->getType();
     }
     return $extras;
 }
开发者ID:llapgoch,项目名称:magento2-developer-toolbar,代码行数:20,代码来源:BlockPanel.php

示例5: buildEntries

 protected function buildEntries(MagentoLayout $layout, &$structure, $name = 'root', $alias = '', $level = 0)
 {
     if (!isset($structure[$name])) {
         return [];
     }
     $instance = $layout->getBlock($name);
     $block = $structure[$name];
     $entries = [];
     $entries[] = ['level' => $level, 'name' => $name, 'alias' => $alias, 'type' => $block['type'], 'label' => isset($block['label']) ? $block['label'] : '', 'extra' => array_filter(['htmlTag' => isset($block['htmlTag']) ? $block['htmlTag'] : '', 'htmlId' => isset($block['htmlId']) ? $block['htmlId'] : '', 'htmlClass' => isset($block['htmlClass']) ? $block['htmlClass'] : '', 'template' => $instance ? $instance->getTemplate() : ''])];
     if (isset($block['children'])) {
         foreach ($block['children'] as $child => $alias) {
             $entries = array_merge($entries, $this->buildEntries($layout, $structure, $child, $alias, $level + 1));
         }
     }
     return $entries;
 }
开发者ID:balloz,项目名称:magento2-developer-toolbar,代码行数:16,代码来源:Layout.php

示例6: getBlock

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


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