protected function MenuActiveTrail::doGetActiveTrailIds

protected MenuActiveTrail::doGetActiveTrailIds($menu_name)

Helper method for ::getActiveTrailIds().

File

core/lib/Drupal/Core/Menu/MenuActiveTrail.php, line 98

Class

MenuActiveTrail
Provides the default implementation of the active menu trail service.

Namespace

Drupal\Core\Menu

Code

protected function doGetActiveTrailIds($menu_name) {
  // Parent ids; used both as key and value to ensure uniqueness.
  // We always want all the top-level links with parent == ''.
  $active_trail = array('' => '');

  // If a link in the given menu indeed matches the route, then use it to
  // complete the active trail.
  if ($active_link = $this->getActiveLink($menu_name)) {
    if ($parents = $this->menuLinkManager->getParentIds($active_link->getPluginId())) {
      $active_trail = $parents + $active_trail;
    }
  }

  return $active_trail;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuActiveTrail.php/function/MenuActiveTrail::doGetActiveTrailIds/8.1.x