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


PHP ViewInterface::getLayout方法代码示例

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


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

示例1: execute

 /**
  * Push `trackSiteSearch' to tracker on search result page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Henhed\Piwik\Observer\SearchResultObserver
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_dataHelper->isTrackingEnabled()) {
         return $this;
     }
     $query = $this->_queryFactory->get();
     $piwikBlock = $this->_view->getLayout()->getBlock('piwik.tracker');
     /* @var $query \Magento\Search\Model\Query */
     /* @var $piwikBlock \Henhed\Piwik\Block\Piwik */
     $keyword = $query->getQueryText();
     $resultsCount = $query->getNumResults();
     if (is_null($resultsCount)) {
         // If this is a new search query the result count hasn't been saved
         // yet so we have to fetch it from the search result block instead.
         $resultBock = $this->_view->getLayout()->getBlock('search.result');
         /* @var $resultBock \Magento\CatalogSearch\Block\Result */
         if ($resultBock) {
             $resultsCount = $resultBock->getResultCount();
         }
     }
     if (is_null($resultsCount)) {
         $this->_piwikTracker->trackSiteSearch($keyword);
     } else {
         $this->_piwikTracker->trackSiteSearch($keyword, false, (int) $resultsCount);
     }
     if ($piwikBlock) {
         // Don't push `trackPageView' when `trackSiteSearch' is set
         $piwikBlock->setSkipTrackPageView(true);
     }
     return $this;
 }
开发者ID:henkelund,项目名称:magento2-henhed-piwik,代码行数:37,代码来源:SearchResultObserver.php

示例2: prepareAndRender

 /**
  * Prepares product view page - inits layout and all needed stuff
  *
  * $params can have all values as $params in \Magento\Catalog\Helper\Product - initProduct().
  * Plus following keys:
  *   - 'buy_request' - \Magento\Framework\Object holding buyRequest to configure product
  *   - 'specify_options' - boolean, whether to show 'Specify options' message
  *   - 'configure_mode' - boolean, whether we're in Configure-mode to edit product configuration
  *
  * @param int $productId
  * @param \Magento\Framework\App\Action\Action $controller
  * @param null|\Magento\Framework\Object $params
  *
  * @return \Magento\Catalog\Helper\Product\View
  * @throws \Magento\Framework\Model\Exception
  */
 public function prepareAndRender($productId, $controller, $params = null)
 {
     // Prepare data
     $productHelper = $this->_catalogProduct;
     if (!$params) {
         $params = new \Magento\Framework\Object();
     }
     // Standard algorithm to prepare and render product view page
     $product = $productHelper->initProduct($productId, $controller, $params);
     if (!$product) {
         throw new \Magento\Framework\Model\Exception(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED);
     }
     $buyRequest = $params->getBuyRequest();
     if ($buyRequest) {
         $productHelper->prepareProductOptions($product, $buyRequest);
     }
     if ($params->hasConfigureMode()) {
         $product->setConfigureMode($params->getConfigureMode());
     }
     $this->_eventManager->dispatch('catalog_controller_product_view', array('product' => $product));
     $this->_catalogSession->setLastViewedProductId($product->getId());
     $this->initProductLayout($product, $controller, $params);
     if ($controller instanceof \Magento\Catalog\Controller\Product\View\ViewInterface) {
         $this->_view->getLayout()->initMessages($this->messageGroups);
     } else {
         throw new \Magento\Framework\Model\Exception(__('Bad controller interface for showing product'), $this->ERR_BAD_CONTROLLER_INTERFACE);
     }
     $this->_view->renderLayout();
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:46,代码来源:View.php

示例3: _renderPage

 /**
  * Renders CMS page
  *
  * @param Action $action
  * @param int $pageId
  * @param bool $renderLayout
  * @return bool
  */
 protected function _renderPage(Action $action, $pageId = null, $renderLayout = true)
 {
     if (!is_null($pageId) && $pageId !== $this->_page->getId()) {
         $delimiterPosition = strrpos($pageId, '|');
         if ($delimiterPosition) {
             $pageId = substr($pageId, 0, $delimiterPosition);
         }
         $this->_page->setStoreId($this->_storeManager->getStore()->getId());
         if (!$this->_page->load($pageId)) {
             return false;
         }
     }
     if (!$this->_page->getId()) {
         return false;
     }
     $inRange = $this->_localeDate->isScopeDateInInterval(null, $this->_page->getCustomThemeFrom(), $this->_page->getCustomThemeTo());
     if ($this->_page->getCustomTheme()) {
         if ($inRange) {
             $this->_design->setDesignTheme($this->_page->getCustomTheme());
         }
     }
     if ($this->_page->getPageLayout()) {
         if ($this->_page->getCustomPageLayout() && $this->_page->getCustomPageLayout() != 'empty' && $inRange) {
             $handle = $this->_page->getCustomPageLayout();
         } else {
             $handle = $this->_page->getPageLayout();
         }
         $this->pageConfig->setPageLayout($handle);
     }
     $this->_view->getPage()->initLayout();
     $this->_view->getLayout()->getUpdate()->addHandle('cms_page_view');
     $this->_view->addPageLayoutHandles(array('id' => $this->_page->getIdentifier()));
     $this->_eventManager->dispatch('cms_page_render', array('page' => $this->_page, 'controller_action' => $action));
     $this->_view->loadLayoutUpdates();
     if ($this->_page->getCustomLayoutUpdateXml() && $inRange) {
         $layoutUpdate = $this->_page->getCustomLayoutUpdateXml();
     } else {
         $layoutUpdate = $this->_page->getLayoutUpdateXml();
     }
     if (!empty($layoutUpdate)) {
         $this->_view->getLayout()->getUpdate()->addUpdate($layoutUpdate);
     }
     $this->_view->generateLayoutXml()->generateLayoutBlocks();
     $contentHeadingBlock = $this->_view->getLayout()->getBlock('page_content_heading');
     if ($contentHeadingBlock) {
         $contentHeading = $this->_escaper->escapeHtml($this->_page->getContentHeading());
         $contentHeadingBlock->setContentHeading($contentHeading);
     }
     /* @TODO: Move catalog and checkout storage types to appropriate modules */
     $messageBlock = $this->_view->getLayout()->getMessagesBlock();
     $messageBlock->addStorageType($this->messageManager->getDefaultGroup());
     $messageBlock->addMessages($this->messageManager->getMessages(true));
     if ($renderLayout) {
         $this->_view->renderLayout();
     }
     return true;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:65,代码来源:Page.php

示例4: getPaymentMethodsHtml

 /**
  * Get payment method step html
  *
  * @param \Magento\Framework\App\ViewInterface $view
  * @return string
  */
 public function getPaymentMethodsHtml(\Magento\Framework\App\ViewInterface $view)
 {
     $layout = $view->getLayout();
     $update = $layout->getUpdate();
     $update->load('checkout_onepage_paymentmethod');
     $layout->generateXml();
     $layout->generateElements();
     $output = $layout->getOutput();
     return $output;
 }
开发者ID:steegi,项目名称:paystand-magento2,代码行数:16,代码来源:Data.php

示例5: execute

 /**
  * Set data for response of frontend saveOrder action
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $this->_coreRegistry->registry('hss_order');
     if ($order && $order->getId()) {
         $payment = $order->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
             $result = $observer->getData('result')->getData();
             if (empty($result['error'])) {
                 $this->_view->loadLayout('checkout_onepage_review', true, true, false);
                 $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
                 $result['update_section'] = ['name' => 'paypaliframe', 'html' => $html];
                 $result['redirect'] = false;
                 $result['success'] = false;
                 $observer->getData('result')->setData($result);
             }
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:SetResponseAfterSaveOrderObserver.php

示例6: _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

示例7: setResponseAfterSaveOrder

 /**
  * Set data for response of frontend saveOrder action
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function setResponseAfterSaveOrder(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $this->_coreRegistry->registry('hss_order');
     if ($order && $order->getId()) {
         $payment = $order->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
             /* @var $controller \Magento\Framework\App\Action\Action */
             $controller = $observer->getEvent()->getData('controller_action');
             $result = $this->_coreData->jsonDecode($controller->getResponse()->getBody('default'));
             if (empty($result['error'])) {
                 $this->_view->loadLayout('checkout_onepage_review', true, true, false);
                 $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
                 $result['update_section'] = array('name' => 'paypaliframe', 'html' => $html);
                 $result['redirect'] = false;
                 $result['success'] = false;
                 $controller->getResponse()->clearHeader('Location');
                 $controller->getResponse()->representJson($this->_coreData->jsonEncode($result));
             }
         }
     }
     return $this;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:29,代码来源:Observer.php


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