當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ViewInterface::generateLayoutBlocks方法代碼示例

本文整理匯總了PHP中Magento\Framework\App\ViewInterface::generateLayoutBlocks方法的典型用法代碼示例。如果您正苦於以下問題:PHP ViewInterface::generateLayoutBlocks方法的具體用法?PHP ViewInterface::generateLayoutBlocks怎麽用?PHP ViewInterface::generateLayoutBlocks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\App\ViewInterface的用法示例。


在下文中一共展示了ViewInterface::generateLayoutBlocks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _initConfigureResultLayout

 /**
  * Init composite product configuration layout
  *
  * $isOk - true or false, whether action was completed nicely or with some error
  * If $isOk is FALSE (some error during configuration), so $productType must be null
  *
  * @param bool $isOk
  * @param string $productType
  * @return $this
  */
 protected function _initConfigureResultLayout($isOk, $productType)
 {
     $update = $this->_view->getLayout()->getUpdate();
     if ($isOk) {
         $update->addHandle('CATALOG_PRODUCT_COMPOSITE_CONFIGURE')->addHandle('catalog_product_view_type_' . $productType);
     } else {
         $update->addHandle('CATALOG_PRODUCT_COMPOSITE_CONFIGURE_ERROR');
     }
     $this->_view->loadLayoutUpdates();
     $this->_view->generateLayoutXml();
     $this->_view->generateLayoutBlocks();
     return $this;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:23,代碼來源:Composite.php

示例2: initProductLayout

 /**
  * Inits layout for viewing product page
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\App\Action\Action $controller
  * @param null|\Magento\Framework\Object $params
  *
  * @return \Magento\Catalog\Helper\Product\View
  */
 public function initProductLayout($product, $controller, $params = null)
 {
     $settings = $this->_catalogDesign->getDesignSettings($product);
     if ($settings->getCustomDesign()) {
         $this->_catalogDesign->applyCustomDesign($settings->getCustomDesign());
     }
     $update = $this->_view->getLayout()->getUpdate();
     $update->addHandle('default');
     if ($params && $params->getBeforeHandles()) {
         foreach ($params->getBeforeHandles() as $handle) {
             $this->_view->addPageLayoutHandles(array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()), $handle);
         }
     }
     $this->_view->addPageLayoutHandles(array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()));
     if ($params && $params->getAfterHandles()) {
         foreach ($params->getAfterHandles() as $handle) {
             $this->_view->addPageLayoutHandles(array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()), $handle);
         }
     }
     $this->_view->loadLayoutUpdates();
     // Apply custom layout update once layout is loaded
     $layoutUpdates = $settings->getLayoutUpdates();
     if ($layoutUpdates) {
         if (is_array($layoutUpdates)) {
             foreach ($layoutUpdates as $layoutUpdate) {
                 $update->addUpdate($layoutUpdate);
             }
         }
     }
     $this->_view->generateLayoutXml();
     $this->_view->generateLayoutBlocks();
     // Apply custom layout (page) template once the blocks are generated
     if ($settings->getPageLayout()) {
         $this->_pageLayout->applyTemplate($settings->getPageLayout());
     }
     $currentCategory = $this->_coreRegistry->registry('current_category');
     $root = $this->_view->getLayout()->getBlock('root');
     if ($root) {
         $controllerClass = $this->_request->getFullActionName();
         if ($controllerClass != 'catalog-product-view') {
             $root->addBodyClass('catalog-product-view');
         }
         $root->addBodyClass('product-' . $product->getUrlKey());
         if ($currentCategory instanceof \Magento\Catalog\Model\Category) {
             $root->addBodyClass('categorypath-' . $currentCategory->getUrlPath())->addBodyClass('category-' . $currentCategory->getUrlKey());
         }
     }
     return $this;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:58,代碼來源:View.php


注:本文中的Magento\Framework\App\ViewInterface::generateLayoutBlocks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。