protected function MenutrailbypathActivetrail::getActiveTrailLink in Menu Trail By Path 7.3
Fetches the deepest, heaviest menu link which matches the deepest trail path url.
Parameters
string $menu_name: The menu within which to find the active trail link.
Return value
stdClass|NULL The menu link for the given menu, or NULL if there is no matching menu link.
1 call to MenutrailbypathActivetrail::getActiveTrailLink()
- MenutrailbypathActivetrail::setActivetrail in src/
MenutrailbypathActivetrail.inc - Set the active trail for the specified menu
File
- src/
MenutrailbypathActivetrail.inc, line 78
Class
Code
protected function getActiveTrailLink($menu_name) {
$menu_links = array_reverse($this->menuHelper
->getMenuLinks($menu_name));
$trail_paths = array_reverse($this->pathHelper
->getPaths());
foreach ($trail_paths as $trail_path) {
$trail_path_url = $this->urlHelper
->getUrl($trail_path);
foreach ($menu_links as $menu_link) {
if ($menu_link->menu_path_by_trail_url == $trail_path_url) {
return $menu_link;
}
}
}
return NULL;
}