當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。