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


PHP AbstractBlock::getNameInLayout方法代码示例

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


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

示例1: _wrapEsi

 /**
  * Replace the output of the block, containing ttl attribute, with ESI tag
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @param \Magento\Framework\View\Layout $layout
  * @return string
  */
 protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block, \Magento\Framework\View\Layout $layout)
 {
     $url = $block->getUrl('page_cache/block/esi', ['blocks' => json_encode([$block->getNameInLayout()]), 'handles' => json_encode($layout->getUpdate()->getHandles())]);
     // Varnish does not support ESI over HTTPS must change to HTTP
     $url = substr($url, 0, 5) === 'https' ? 'http' . substr($url, 5) : $url;
     return sprintf('<esi:include src="%s" />', $url);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:ProcessLayoutRenderElement.php

示例2: testSetGetNameInLayout

 public function testSetGetNameInLayout()
 {
     // Basic setting/getting
     $this->assertEmpty($this->_block->getNameInLayout());
     $name = uniqid('name');
     $this->_block->setNameInLayout($name);
     $this->assertEquals($name, $this->_block->getNameInLayout());
     // Setting second time, along with the layout
     $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface');
     $layout->createBlock('Magento\\Framework\\View\\Element\\Template', $name);
     $block = $layout->getBlock($name);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $block);
     $block->setNameInLayout($name);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $layout->getBlock($name));
     $this->assertEquals($name, $block->getNameInLayout());
     $this->assertTrue($layout->hasElement($name));
     $newName = 'new_name';
     $block->setNameInLayout($newName);
     $this->assertTrue($layout->hasElement($newName));
     $this->assertFalse($layout->hasElement($name));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:21,代码来源:AbstractBlockTest.php

示例3: aroundGetChildData

 public function aroundGetChildData(AbstractBlock $subject, callable $proceed, $alias, $key = '')
 {
     $returnValue = $proceed($alias, $key);
     if (null === $returnValue) {
         $layout = $subject->getLayout();
         if (!$layout) {
             return false;
         }
         $name = $layout->getChildName($subject->getNameInLayout(), $alias);
         if ($layout->isContainer($name)) {
             $returnValue = $layout->getElementProperty($name, $key);
         }
     }
     return $returnValue;
 }
开发者ID:outeredge,项目名称:magento-container-group-module,代码行数:15,代码来源:AbstractBlockPlugin.php

示例4: pushButtons

 /**
  * {@inheritdoc}
  */
 public function pushButtons(\Magento\Framework\View\Element\AbstractBlock $context, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList)
 {
     foreach ($buttonList->getItems() as $buttons) {
         /** @var \Magento\Backend\Block\Widget\Button\Item $item */
         foreach ($buttons as $item) {
             $containerName = $context->getNameInLayout() . '-' . $item->getButtonKey();
             $container = $this->createContainer($context->getLayout(), $containerName, $item);
             if ($item->hasData('name')) {
                 $item->setData('element_name', $item->getName());
             }
             if ($container) {
                 $container->setContext($context);
                 $toolbar = $this->getToolbar($context, $item->getRegion());
                 $toolbar->setChild($item->getButtonKey(), $container);
             }
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:Toolbar.php

示例5: addBlock

 /**
  * Add a block to registry, create new object if needed
  *
  * @param string|\Magento\Framework\View\Element\AbstractBlock $block
  * @param string $name
  * @param string $parent
  * @param string $alias
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 public function addBlock($block, $name = '', $parent = '', $alias = '')
 {
     $this->build();
     if ($block instanceof \Magento\Framework\View\Element\AbstractBlock) {
         $name = $name ?: $block->getNameInLayout();
     } else {
         $block = $this->_createBlock($block, $name);
     }
     $name = $this->structure->createStructuralElement($name, Element::TYPE_BLOCK, $name ?: get_class($block));
     $this->setBlock($name, $block);
     $block->setNameInLayout($name);
     if ($parent) {
         $this->structure->setAsChild($name, $parent, $alias);
     }
     $block->setLayout($this);
     return $block;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:26,代码来源:Layout.php

示例6: insert

 /**
  * Insert child element into specified position
  *
  * By default inserts as first element into children list
  *
  * @param \Magento\Framework\View\Element\AbstractBlock|string $element
  * @param string|int|null $siblingName
  * @param bool $after
  * @param string $alias
  * @return $this|bool
  */
 public function insert($element, $siblingName = 0, $after = true, $alias = '')
 {
     $layout = $this->getLayout();
     if (!$layout) {
         return false;
     }
     if ($element instanceof \Magento\Framework\View\Element\AbstractBlock) {
         $elementName = $element->getNameInLayout();
     } else {
         $elementName = $element;
     }
     $layout->setChild($this->_nameInLayout, $elementName, $alias);
     $layout->reorderChild($this->_nameInLayout, $elementName, $siblingName, $after);
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:AbstractBlock.php

示例7: _wrapEsi

 /**
  * Replace the output of the block, containing ttl attribute, with ESI tag
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @return string
  */
 protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block)
 {
     $url = $block->getUrl('page_cache/block/esi', array('blocks' => json_encode(array($block->getNameInLayout())), 'handles' => json_encode($this->_helper->getActualHandles())));
     return sprintf('<esi:include src="%s" />', $url);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Observer.php

示例8: generateAction

 /**
  * Run action defined in layout update
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @param string $methodName
  * @param array $actionArguments
  * @return void
  */
 protected function generateAction($block, $methodName, $actionArguments)
 {
     $profilerKey = 'BLOCK_ACTION:' . $block->getNameInLayout() . '>' . $methodName;
     \Magento\Framework\Profiler::start($profilerKey);
     $args = $this->evaluateArguments($actionArguments);
     call_user_func_array([$block, $methodName], $args);
     \Magento\Framework\Profiler::stop($profilerKey);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Block.php

示例9: _wrapEsi

 /**
  * Replace the output of the block, containing ttl attribute, with ESI tag
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @param \Magento\Framework\View\Layout $layout
  * @return string
  */
 protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block, \Magento\Framework\View\Layout $layout)
 {
     $url = $block->getUrl('page_cache/block/esi', ['blocks' => json_encode([$block->getNameInLayout()]), 'handles' => json_encode($layout->getUpdate()->getHandles())]);
     return sprintf('<esi:include src="%s" />', $url);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:ProcessLayoutRenderElement.php

示例10: moveBlockToContainer

 /**
  * Set specified block as an anonymous child to specified container
  *
  * The block will be moved to the container from previous parent after all other elements
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @param string $containerName
  * @return $this
  */
 protected function moveBlockToContainer(View\Element\AbstractBlock $block, $containerName)
 {
     $this->layout->setChild($containerName, $block->getNameInLayout(), '');
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Page.php

示例11: renderLink

 /**
  * Render Block
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $link
  * @return string
  */
 public function renderLink(\Magento\Framework\View\Element\AbstractBlock $link)
 {
     return $this->_layout->renderElement($link->getNameInLayout());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Links.php

示例12: _moveBlockToContainer

 /**
  * Set specified block as an anonymous child to specified container
  *
  * The block will be moved to the container from previous parent after all other elements
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $block
  * @param string $containerName
  * @return $this
  */
 private function _moveBlockToContainer(\Magento\Framework\View\Element\AbstractBlock $block, $containerName)
 {
     $this->_view->getLayout()->setChild($containerName, $block->getNameInLayout(), '');
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AbstractAction.php

示例13: df_parent_name

/**
 * 2016-11-30
 * Наивное $e->getParentBlock()->getNameInLayout() некорректно,
 * потому что родительским элементом для $e может быть не только блок,
 * но и контейнер, и тогда $e->getParentBlock() вернёт false.
 * @param AbstractBlock|string $e
 * @return string|null
 */
function df_parent_name($e)
{
    return df_ftn(df_layout()->getParentName($e instanceof AbstractBlock ? $e->getNameInLayout() : $e));
}
开发者ID:mage2pro,项目名称:core,代码行数:12,代码来源:layout.php

示例14: _getBlockNamePath

 /**
  * @param AbstractBlock $block
  *
  * @return string
  */
 protected function _getBlockNamePath(AbstractBlock $block)
 {
     $layout = $block->getLayout();
     $blockName = $block->getNameInLayout();
     $path = $this->_getElementPath($layout, $blockName);
     return isset($path) ? $path . " / " . $blockName : $blockName;
 }
开发者ID:marynychsv,项目名称:magento2debugging,代码行数:12,代码来源:DebugHints.php

示例15: afterToHtml

 public function afterToHtml(\Magento\Framework\View\Element\AbstractBlock $subject, $result)
 {
     $this->agent->addCustomParameter('block::' . $subject->getNameInLayout(), 1);
     return $result;
 }
开发者ID:baisoo,项目名称:Yireo_NewRelic2,代码行数:5,代码来源:AbstractBlock.php


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