當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。