You are here

protected function GinToolbarActiveTrail::getLinkByRoutes in Gin Toolbar 8

Get a possible link to base the active trail on.

Parameters

string $menu_name: The name of the menu.

array $routes: An array of route name & route params combinations in order of relevance.

1 call to GinToolbarActiveTrail::getLinkByRoutes()
GinToolbarActiveTrail::doGetActiveTrailIds in src/Menu/GinToolbarActiveTrail.php
Change the active trail for node add/edit/view routes.

File

src/Menu/GinToolbarActiveTrail.php, line 79

Class

GinToolbarActiveTrail
Class GinToolbarActiveTrail.

Namespace

Drupal\gin_toolbar\Menu

Code

protected function getLinkByRoutes(string $menu_name, array $routes) {
  foreach ($routes as $route) {
    [
      $route_name,
      $route_params,
    ] = $route;
    $links = $this->menuLinkManager
      ->loadLinksByRoute($route_name, $route_params, $menu_name);
    foreach ($links as $link) {
      if (!empty($link
        ->getParent())) {
        return $link;
      }
    }
  }
  return NULL;
}