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


PHP LayoutInterface::getBlock方法代码示例

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


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

示例1: setGoogleAnalyticsOnOrderSuccessPageView

 /**
  * Add order information into GA block to render on checkout success pages
  *
  * @param EventObserver $observer
  * @return void
  */
 public function setGoogleAnalyticsOnOrderSuccessPageView(EventObserver $observer)
 {
     $orderIds = $observer->getEvent()->getOrderIds();
     if (empty($orderIds) || !is_array($orderIds)) {
         return;
     }
     $block = $this->_layout->getBlock('google_analytics');
     if ($block) {
         $block->setOrderIds($orderIds);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Observer.php

示例2: execute

 /**
  * Add order information into GA block to render on checkout success pages
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     $orderIds = $observer->getEvent()->getOrderIds();
     if (empty($orderIds) || !is_array($orderIds)) {
         return;
     }
     $block = $this->_layout->getBlock('magepal_gtm_datalayer');
     if ($block) {
         $block->setOrderIds($orderIds);
     }
 }
开发者ID:magepal,项目名称:magento2-googletagmanager,代码行数:17,代码来源:OrderSuccessPageViewObserver.php

示例3: getReviewButtonTemplate

 /**
  * Get template for button in order review page if HSS method was selected
  *
  * @param string $name template name
  * @param string $block buttons block name
  * @return string
  */
 public function getReviewButtonTemplate($name, $block)
 {
     $quote = $this->_checkoutSession->getQuote();
     if ($quote) {
         $payment = $quote->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_hssMethods)) {
             return $name;
         }
     }
     $blockObject = $this->_layout->getBlock($block);
     if ($blockObject) {
         return $blockObject->getTemplate();
     }
     return '';
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:22,代码来源:Hss.php

示例4: getToolbar

 /**
  * Return button parent block
  *
  * @param \Magento\Framework\View\Element\AbstractBlock $context
  * @param string $region
  * @return \Magento\Backend\Block\Template
  */
 protected function getToolbar(\Magento\Framework\View\Element\AbstractBlock $context, $region)
 {
     $parent = null;
     if (!$region || $region == 'header' || $region == 'footer') {
         $parent = $context;
     } elseif ($region == 'toolbar') {
         $parent = $this->layout->getBlock('page.actions.toolbar');
     } else {
         $parent = $this->layout->getBlock($region);
     }
     if ($parent) {
         return $parent;
     }
     return $context;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:22,代码来源:Toolbar.php

示例5: testGridContainsMassactionColumn

 public function testGridContainsMassactionColumn()
 {
     $this->_layout->getBlock('admin.test.grid')->toHtml();
     $gridMassactionColumn = $this->_layout->getBlock('admin.test.grid')->getColumnSet()->getChildBlock('massaction');
     $this->assertNotNull($gridMassactionColumn, 'Massaction column does not exist in the grid column set');
     $this->assertInstanceOf('Magento\\Backend\\Block\\Widget\\Grid\\Column', $gridMassactionColumn, 'Massaction column is not an instance of \\Magento\\Backend\\Block\\Widget\\Column');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:MassactionTest.php

示例6: testInitProductLayout

 /**
  * @magentoAppIsolation enabled
  * @magentoAppArea frontend
  */
 public function testInitProductLayout()
 {
     $uniqid = uniqid();
     /** @var $product \Magento\Catalog\Model\Product */
     $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product');
     $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE)->setId(99)->setUrlKey($uniqid);
     /** @var $objectManager \Magento\TestFramework\ObjectManager */
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $objectManager->get('Magento\\Framework\\Registry')->register('product', $product);
     $this->_helper->initProductLayout($product, $this->_controller);
     $rootBlock = $this->_layout->getBlock('root');
     $this->assertInstanceOf('Magento\\Theme\\Block\\Html', $rootBlock);
     $this->assertContains("product-{$uniqid}", $rootBlock->getBodyClass());
     $handles = $this->_layout->getUpdate()->getHandles();
     $this->assertContains('catalog_product_view_type_simple', $handles);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:20,代码来源:ViewTest.php

示例7: getBlockHtml

 /**
  * Retrieve block html
  *
  * @param   string $name
  * @return  string
  */
 public function getBlockHtml($name)
 {
     $block = $this->_layout->getBlock($name);
     if ($block) {
         return $block->toHtml();
     }
     return '';
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AbstractBlock.php

示例8: getUiElementView

 /**
  * Get UI Element View
  *
  * @param string $uiElementName
  * @return UiComponentInterface
  * @throws \InvalidArgumentException
  */
 public function getUiElementView($uiElementName)
 {
     /** @var UiComponentInterface $view */
     $view = $this->layout->getBlock($uiElementName);
     if (!$view instanceof UiComponentInterface) {
         throw new \InvalidArgumentException(sprintf('UI Element "%s" must implement \\Magento\\Framework\\View\\Element\\UiComponentInterface', $uiElementName));
     }
     return $view;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:UiComponentFactory.php

示例9: getProductPriceHtml

 /**
  * Return HTML block with product price
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return string
  */
 public function getProductPriceHtml(\Magento\Catalog\Model\Product $product)
 {
     $price = '';
     /** @var \Magento\Framework\Pricing\Render $priceRender */
     $priceRender = $this->layout->getBlock('product.price.render.default');
     if (!$priceRender) {
         $priceRender = $this->layout->createBlock('Magento\\Framework\\Pricing\\Render', 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']]);
     }
     if ($priceRender) {
         $price = $priceRender->render('wishlist_configured_price', $product, ['zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST]);
     }
     return $price;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:Wishlist.php

示例10: fire

 /**
  * Run all methods declared in persistent configuration
  *
  * @return $this
  */
 public function fire()
 {
     foreach ($this->collectInstancesToEmulate() as $type => $elements) {
         if (!is_array($elements)) {
             continue;
         }
         foreach ($elements as $info) {
             switch ($type) {
                 case 'blocks':
                     $this->fireOne($info, $this->_layout->getBlock($info['name_in_layout']));
                     break;
             }
         }
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:Config.php

示例11: getCurrentPageLayout

 /**
  * Retrieve current applied page layout
  *
  * @return \Magento\Framework\Object|boolean
  */
 public function getCurrentPageLayout()
 {
     if ($this->_layout->getBlock('root') && $this->_layout->getBlock('root')->getLayoutCode()) {
         return $this->_config->getPageLayout($this->_layout->getBlock('root')->getLayoutCode());
     }
     // All loaded handles
     $handles = $this->_layout->getUpdate()->getHandles();
     // Handles used in page layouts
     $pageLayoutHandles = $this->_config->getPageLayoutHandles();
     // Applied page layout handles
     $appliedHandles = array_intersect($handles, $pageLayoutHandles);
     if (empty($appliedHandles)) {
         return false;
     }
     $currentHandle = array_pop($appliedHandles);
     $layoutCode = array_search($currentHandle, $pageLayoutHandles, true);
     return $this->_config->getPageLayout($layoutCode);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:23,代码来源:Layout.php

示例12: testGetJs

 public function testGetJs()
 {
     $expected = uniqid();
     $this->_layout->getBlock('child')->setJs($expected);
     $this->assertEquals($expected, $this->_block->getJs());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:6,代码来源:ColumnTest.php

示例13: _applyAccountLinksPersistentData

 /**
  * Emulate 'account links' block with persistent data
  *
  * @return void
  */
 protected function _applyAccountLinksPersistentData()
 {
     if (!$this->_layout->getBlock('header.additional')) {
         $this->_layout->addBlock('Magento\\Persistent\\Block\\Header\\Additional', 'header.additional');
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:Observer.php

示例14: getBlock

 /**
  * Obtain block object
  *
  * @param string $name
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 public function getBlock($name)
 {
     return $this->layout->getBlock($name);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Layout.php

示例15: _getElementPath

 /**
  * @param string $nameElement
  * @param LayoutInterface $layout
  *
  * @return null|string
  */
 protected function _getElementPath(LayoutInterface $layout, $nameElement)
 {
     $parentName = $layout->getParentName($nameElement);
     if (!$parentName) {
         return null;
     }
     $parentBlock = $layout->getBlock($parentName);
     $pathName = $parentBlock ? $parentName : "[{$parentName}]";
     $path = isset($parentName) && $parentName !== false ? $this->_getElementPath($layout, $parentName) : null;
     return isset($path) ? $path . " / " . $pathName : $pathName;
 }
开发者ID:marynychsv,项目名称:magento2debugging,代码行数:17,代码来源:DebugHints.php


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