本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例5: addTestimonialToTopmenuItems
public function addTestimonialToTopmenuItems(\Magento\Framework\Event\Observer $observer)
{
$block = $observer->getEvent()->getBlock();
$block->addIdentity('testimonial');
$this->_addTestimonialMenu('testimonial', $observer->getMenu(), $block);
}