本文整理汇总了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);
}
示例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));
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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));
}
示例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;
}
示例15: afterToHtml
public function afterToHtml(\Magento\Framework\View\Element\AbstractBlock $subject, $result)
{
$this->agent->addCustomParameter('block::' . $subject->getNameInLayout(), 1);
return $result;
}