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


PHP Observer::getMenu方法代码示例

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


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

示例1: execute

 /**
  * @param $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $menu = $observer->getMenu();
     $tree = $menu->getTree();
     $fullAction = $this->request->getFullActionName();
     $selectedActions = ['gemtoo_blog_article_index', 'gemtoo_blog_article_view'];
     $articleNodeId = 'articles';
     $data = ['name' => __('Blog'), 'id' => $articleNodeId, 'url' => $this->articleUrl->getListUrl(), 'is_active' => in_array($fullAction, $selectedActions)];
     $articlesNode = new Node($data, 'id', $tree, $menu);
     $menu->addChild($articlesNode);
     return $this;
 }
开发者ID:pleminh,项目名称:Gemtoo,代码行数:16,代码来源:TopMenu.php

示例2: execute

 /**
  * Page block html topmenu gethtml before
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_scopeConfig->isSetFlag(static::XML_PATH_TOP_MENU_SHOW_ITEM, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         return;
     }
     /** @var \Magento\Framework\Data\Tree\Node $menu */
     $menu = $observer->getMenu();
     $block = $observer->getBlock();
     $tree = $menu->getTree();
     $data = ['name' => $this->_scopeConfig->getValue(static::XML_PATH_TOP_MENU_ITEM_TEXT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'id' => 'magefan-blog', 'url' => $this->_url->getBaseUrl(), 'is_active' => $block->getRequest()->getModuleName() == 'blog'];
     $node = new Node($data, 'id', $tree, $menu);
     $menu->addChild($node);
 }
开发者ID:magefan,项目名称:module-blog,代码行数:20,代码来源:PageBlockHtmlTopmenuBethtmlBeforeObserver.php

示例3: execute

 /**
  * @param $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     /** @var \Magento\Framework\Data\Tree\Node $menu */
     $menu = $observer->getMenu();
     $tree = $menu->getTree();
     $fullAction = $this->request->getFullActionName();
     $selectedActions = ['sample_news_author_index', 'sample_news_author_view'];
     $authorNodeId = 'authors';
     $data = ['name' => __('Authors'), 'id' => $authorNodeId, 'url' => $this->authorUrl->getListUrl(), 'is_active' => in_array($fullAction, $selectedActions)];
     $authorsNode = new Node($data, 'id', $tree, $menu);
     $menu->addChild($authorsNode);
     return $this;
 }
开发者ID:sz-bill,项目名称:Magento2.x,代码行数:17,代码来源:TopMenu.php

示例4: addCatalogToTopmenuItems

 /**
  * Adds catalog categories to top menu
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function addCatalogToTopmenuItems(\Magento\Framework\Event\Observer $observer)
 {
     $block = $observer->getEvent()->getBlock();
     $block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG);
     $this->_addCategoriesToMenu($this->_catalogCategory->getStoreCategories(), $observer->getMenu(), $block);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Observer.php

示例5: addTestimonialToTopmenuItems

 public function addTestimonialToTopmenuItems(\Magento\Framework\Event\Observer $observer)
 {
     $block = $observer->getEvent()->getBlock();
     $block->addIdentity('testimonial');
     $this->_addTestimonialMenu('testimonial', $observer->getMenu(), $block);
 }
开发者ID:ktplKunj,项目名称:TestMagento,代码行数:6,代码来源:Observer.php


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