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


PHP Context::getUrlBuilder方法代码示例

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


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

示例1: _prepareLayout

 /**
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $category = $this->getCategory();
     $title = $category ? $category->getName() : $this->config->getBlogName();
     $metaTitle = $category ? $category->getMetaTitle() ? $category->getMetaTitle() : $category->getName() : $this->config->getBaseMetaTitle();
     $metaDescription = $category ? $category->getMetaDescription() ? $category->getMetaDescription() : $category->getName() : $this->config->getBaseMetaDescription();
     $metaKeywords = $category ? $category->getMetaKeywords() ? $category->getMetaKeywords() : $category->getName() : $this->config->getBaseMetaKeywords();
     $this->pageConfig->getTitle()->set($metaTitle);
     $this->pageConfig->setDescription($metaDescription);
     $this->pageConfig->setKeywords($metaKeywords);
     /** @var \Magento\Theme\Block\Html\Title $pageMainTitle */
     $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
     if ($pageMainTitle) {
         $pageMainTitle->setPageTitle($title);
     }
     /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbs */
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->context->getUrlBuilder()->getBaseUrl()])->addCrumb('blog', ['label' => $this->config->getBlogName(), 'title' => $this->config->getBlogName(), 'link' => $this->config->getBaseUrl()]);
         if ($category) {
             $ids = $category->getParentIds();
             $ids[] = 0;
             $parents = $this->categoryCollectionFactory->create()->addFieldToFilter('entity_id', $ids)->addNameToSelect()->excludeRoot()->setOrder('level', 'asc');
             /** @var \Mirasvit\Blog\Model\Category $cat */
             foreach ($parents as $cat) {
                 $breadcrumbs->addCrumb($cat->getId(), ['label' => $cat->getName(), 'title' => $cat->getName(), 'link' => $cat->getUrl()]);
             }
             $breadcrumbs->addCrumb($category->getId(), ['label' => $category->getName(), 'title' => $category->getName()]);
         }
     }
     return $this;
 }
开发者ID:mirasvit,项目名称:module-blog,代码行数:37,代码来源:View.php

示例2: __construct

 public function __construct(Template\Context $context, \Celebros\ConversionPro\Helper\Data $helper, \Celebros\ConversionPro\Helper\Search $searchHelper, \Magento\Framework\Registry $registry, array $data = [])
 {
     $this->helper = $helper;
     $this->searchHelper = $searchHelper;
     $this->registry = $registry;
     $this->url = $context->getUrlBuilder();
     parent::__construct($context, $data);
 }
开发者ID:devbelvg,项目名称:M2_ConversionPro_Embedded,代码行数:8,代码来源:View.php

示例3: _prepareLayout

 /**
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $title = $metaTitle = __("Search results for: '%1'", $this->getRequest()->getParam('q'));
     $metaDescription = $this->config->getBaseMetaDescription();
     $metaKeywords = $this->config->getBaseMetaKeywords();
     $this->pageConfig->getTitle()->set($metaTitle);
     $this->pageConfig->setDescription($metaDescription);
     $this->pageConfig->setKeywords($metaKeywords);
     /** @var \Magento\Theme\Block\Html\Title $pageMainTitle */
     $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
     if ($pageMainTitle) {
         $pageMainTitle->setPageTitle($title);
     }
     /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbs */
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->context->getUrlBuilder()->getBaseUrl()])->addCrumb('blog', ['label' => $this->config->getBlogName(), 'title' => $this->config->getBlogName(), 'link' => $this->config->getBaseUrl()])->addCrumb('search', ['label' => $title, 'title' => $title]);
     }
     return $this;
 }
开发者ID:mirasvit,项目名称:module-blog,代码行数:25,代码来源:Result.php

示例4: __construct

 /**
  * Constructor
  *
  * @param View\Element\Template\Context $context
  * @param View\LayoutFactory $layoutFactory
  * @param View\Layout\ReaderPool $layoutReaderPool
  * @param Framework\Translate\InlineInterface $translateInline
  * @param View\Layout\BuilderFactory $layoutBuilderFactory
  * @param View\Layout\GeneratorPool $generatorPool
  * @param View\Page\Config\RendererFactory $pageConfigRendererFactory
  * @param View\Page\Layout\Reader $pageLayoutReader
  * @param string $template
  * @param bool $isIsolated
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(View\Element\Template\Context $context, View\LayoutFactory $layoutFactory, View\Layout\ReaderPool $layoutReaderPool, Framework\Translate\InlineInterface $translateInline, View\Layout\BuilderFactory $layoutBuilderFactory, View\Layout\GeneratorPool $generatorPool, View\Page\Config\RendererFactory $pageConfigRendererFactory, View\Page\Layout\Reader $pageLayoutReader, $template, $isIsolated = false)
 {
     $this->request = $context->getRequest();
     $this->assetRepo = $context->getAssetRepository();
     $this->logger = $context->getLogger();
     $this->urlBuilder = $context->getUrlBuilder();
     $this->pageConfig = $context->getPageConfig();
     $this->pageLayoutReader = $pageLayoutReader;
     $this->viewFileSystem = $context->getViewFileSystem();
     $this->pageConfigRendererFactory = $pageConfigRendererFactory;
     $this->template = $template;
     parent::__construct($context, $layoutFactory, $layoutReaderPool, $translateInline, $layoutBuilderFactory, $generatorPool, $isIsolated);
     $this->initPageConfigReader();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:Page.php


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