MenuTreeStorageMenuHelper.php in Menu Trail By Path 8
File
src/Menu/MenuTreeStorageMenuHelper.php
View source
<?php
namespace Drupal\menu_trail_by_path\Menu;
use Drupal\Core\Menu\MenuLinkManagerInterface;
use Drupal\Core\Menu\MenuTreeStorageInterface;
class MenuTreeStorageMenuHelper implements MenuHelperInterface {
protected $menuLinkManager;
protected $menuTreeStorage;
public function __construct(MenuLinkManagerInterface $menu_link_manager, MenuTreeStorageInterface $menu_tree_storage) {
$this->menuLinkManager = $menu_link_manager;
$this->menuTreeStorage = $menu_tree_storage;
}
public function getMenuLinks($menu_name) {
$menu_links = [];
$menu_plugins = $this->menuTreeStorage
->loadByProperties([
'menu_name' => $menu_name,
]);
foreach ($menu_plugins as $plugin_id => $definition) {
$menu_links[$plugin_id] = $this->menuLinkManager
->createInstance($plugin_id);
}
return $menu_links;
}
}