Drupal 8  8.0.2
MenuActiveTrail Class Reference
Inheritance diagram for MenuActiveTrail:

Public Member Functions

 __construct (MenuLinkManagerInterface $menu_link_manager, RouteMatchInterface $route_match, CacheBackendInterface $cache, LockBackendInterface $lock)
 
 getActiveTrailIds ($menu_name)
 
 getActiveLink ($menu_name=NULL)
 
- Public Member Functions inherited from CacheCollector
 __construct ($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags=array())
 
 has ($key)
 
 get ($key)
 
 set ($key, $value)
 
 delete ($key)
 
 reset ()
 
 clear ()
 
 destruct ()
 

Protected Member Functions

 getCid ()
 
 resolveCacheMiss ($menu_name)
 
 doGetActiveTrailIds ($menu_name)
 
- Protected Member Functions inherited from CacheCollector
 getCid ()
 
 persist ($key, $persist=TRUE)
 
 resolveCacheMiss ($key)
 
 updateCache ($lock=TRUE)
 
 normalizeLockName ($cid)
 
 lazyLoadCache ()
 
 invalidateCache ()
 

Protected Attributes

 $menuLinkManager
 
 $routeMatch
 
- Protected Attributes inherited from CacheCollector
 $cid
 
 $tags
 
 $cache
 
 $lock
 
 $keysToPersist = array()
 
 $keysToRemove = array()
 
 $storage = array()
 
 $cacheCreated
 
 $cacheInvalidated = FALSE
 
 $cacheLoaded = FALSE
 

Detailed Description

Provides the default implementation of the active menu trail service.

It uses the current route name and route parameters to compare with the ones of the menu links.

Constructor & Destructor Documentation

__construct ( MenuLinkManagerInterface  $menu_link_manager,
RouteMatchInterface  $route_match,
CacheBackendInterface  $cache,
LockBackendInterface  $lock 
)

Constructs a object.

Parameters
\Drupal\Core\Menu\MenuLinkManagerInterface$menu_link_managerThe menu link plugin manager.
\Drupal\Core\Routing\RouteMatchInterface$route_matchA route match object for finding the active link.
\Drupal\Core\Cache\CacheBackendInterface$cacheThe cache backend.
\Drupal\Core\Lock\LockBackendInterface$lockThe lock backend.

References Drupal\routeMatch().

Here is the call graph for this function:

Member Function Documentation

doGetActiveTrailIds (   $menu_name)
protected

Helper method for ::getActiveTrailIds().

References MenuActiveTrail\getActiveLink().

Referenced by MenuActiveTrail\resolveCacheMiss().

Here is the call graph for this function:

Here is the caller graph for this function:

getActiveLink (   $menu_name = NULL)

{Fetches a menu link which matches the route name, parameters and menu name.

Parameters
string | NULL$menu_name(optional) The menu within which to find the active link. If omitted, all menus will be searched.
Returns
|NULL The menu link for the given route name, parameters and menu, or NULL if there is no matching menu link or the current user cannot access the current page (i.e. we have a 403 response).
}

Implements MenuActiveTrailInterface.

References CacheCollector\reset(), and Drupal\routeMatch().

Referenced by MenuActiveTrail\doGetActiveTrailIds().

Here is the call graph for this function:

Here is the caller graph for this function:

getActiveTrailIds (   $menu_name)

{Gets the active trail IDs of the specified menu tree.

Parameters
string | NULL$menu_name(optional) The menu name of the requested tree. If omitted, all menu trees will be searched.
Returns
array An array containing the active trail: a list of plugin IDs.
}

This implementation caches all active trail IDs per route match for all menus whose active trails are calculated on that page. This ensures 1 cache get for all active trails per page load, rather than N.

It uses the cache collector pattern to do this.

See Also
::get()

Implements MenuActiveTrailInterface.

getCid ( )
protected

{}

See Also
::getActiveTrailIds()

References Drupal\routeMatch().

Here is the call graph for this function:

resolveCacheMiss (   $menu_name)
protected

{}

See Also
::getActiveTrailIds()

References MenuActiveTrail\doGetActiveTrailIds(), and CacheCollector\persist().

Here is the call graph for this function:


The documentation for this class was generated from the following file: