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


PHP Layout::getAllBlocks方法代码示例

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


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

示例1: _buildEntries

 protected function _buildEntries(&$entries, $block, $alias, $level)
 {
     $blocks = $this->_layout->getAllBlocks();
     $extras = array();
     $extras[] = count($block->getChild()) ? count($block->getChild()) : "-";
     $extras[] = $block->getType();
     if ($block->getType() === 'cms/block') {
         $extras[] = $block->getBlockId();
     } elseif ($block->getType() == 'cms/page') {
         $extras[] = $block->getPage()->getIdentifier();
     } elseif ($template = $block->getTemplate()) {
         $extras[] = $template;
     } else {
         $extras[] = '-';
     }
     $extras[] = get_class($block);
     // sprintf("$offset%s %s\n", $alias, $this->_colorize($extraString, self::COLOR_DARK_GRAY))
     $name = $block->getNameInLayout();
     $entry = array('name' => $name, 'alias' => $alias, 'level' => $level, 'extras' => $extras);
     $profileName = "BLOCK: {$name}";
     if (isset($this->timers[$profileName])) {
         $entry['time'] = $this->timers[$profileName]['sum'] * 1000;
     }
     $entries[] = $entry;
     foreach ($block->getChild() as $alias => $childBlock) {
         $this->_buildEntries($entries, $childBlock, $alias, $level + 1);
     }
 }
开发者ID:llapgoch,项目名称:magento2-developer-toolbar,代码行数:28,代码来源:BlockPanel.php

示例2: testRenameElement

 public function testRenameElement()
 {
     $oldName = 'old_name';
     $newName = 'new_name';
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->structureMock->expects($this->once())->method('renameElement')->with($this->equalTo($oldName), $this->equalTo($newName))->will($this->returnSelf());
     $this->assertSame($this->model, $this->model->setBlock($oldName, $blockMock));
     $this->assertSame($this->model, $this->model->renameElement($oldName, $newName));
     $this->assertSame([$newName => $blockMock], $this->model->getAllBlocks());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:10,代码来源:LayoutTest.php

示例3: testGenerateGetAllBlocks

 /**
  * A smoke test for generating elements
  *
  * See sophisticated tests at \Magento\Framework\View\LayoutDirectivesTest
  * @see \Magento\Framework\View\LayoutDirectivesTest
  * @magentoAppIsolation enabled
  */
 public function testGenerateGetAllBlocks()
 {
     $this->_layout->setXml(simplexml_load_string('<layout>
             <block class="Magento\\Framework\\View\\Element\\Text" name="block1">
                 <block class="Magento\\Framework\\View\\Element\\Text"/>
             </block>
             <block class="Magento\\Framework\\View\\Element\\Text" template="test" ttl="360"/>
             <block class="Magento\\Framework\\View\\Element\\Text"/>
         </layout>', 'Magento\\Framework\\View\\Layout\\Element'));
     $this->assertEquals([], $this->_layout->getAllBlocks());
     $this->_layout->generateElements();
     $expected = ['block1', 'block1_schedule_block0', 'schedule_block1', 'schedule_block2'];
     $this->assertSame($expected, array_keys($this->_layout->getAllBlocks()));
     $child = $this->_layout->getBlock('block1_schedule_block0');
     $this->assertSame($this->_layout->getBlock('block1'), $child->getParentBlock());
     $this->assertEquals('test', $this->_layout->getBlock('schedule_block1')->getData('template'));
     $this->assertEquals('360', $this->_layout->getBlock('schedule_block1')->getData('ttl'));
     $this->assertFalse($this->_layout->getBlock('nonexisting'));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:26,代码来源:LayoutTest.php

示例4: afterGetOutput

 /**
  * Retrieve all identities from blocks for further cache invalidation
  *
  * @param \Magento\Framework\View\Layout $subject
  * @param mixed $result
  * @return mixed
  */
 public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
 {
     if ($this->layout->isCacheable() && $this->config->isEnabled()) {
         $tags = array();
         foreach ($this->layout->getAllBlocks() as $block) {
             if ($block instanceof \Magento\Framework\View\Block\IdentityInterface) {
                 $isEsiBlock = $block->getTtl() > 0;
                 $isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH;
                 if ($isVarnish && $isEsiBlock) {
                     continue;
                 }
                 $tags = array_merge($tags, $block->getIdentities());
             }
         }
         $tags = array_unique($tags);
         $this->response->setHeader('X-Magento-Tags', implode(',', $tags));
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:LayoutPlugin.php

示例5: afterGetOutput

 /**
  * Set X-Cache-Tags header with all the Magento Cache Tags so
  * they can be purged by the CloudFlare API
  *
  * @param \Magento\Framework\View\Layout $subject
  * @param $result
  * @return mixed
  */
 public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
 {
     if (!$subject->isCacheable() || !$this->config->isEnabled()) {
         return $result;
     }
     $tags = [];
     foreach ($subject->getAllBlocks() as $block) {
         if ($block->getIdentities() !== null) {
             $tags = array_merge($tags, $block->getIdentities());
         }
     }
     $tags = array_unique($tags);
     $this->cacheTagsUtil->setCloudFlareCacheTagsResponseHeader($this->response, $tags);
     return $result;
 }
开发者ID:cloudflare,项目名称:cloudflare-magento,代码行数:23,代码来源:LayoutPlugin.php

示例6: getAllBlocks

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


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