function MenuActiveTrail::__construct

Same name in this branch
  1. 11.x core/lib/Drupal/Core/ProxyClass/Menu/MenuActiveTrail.php \Drupal\Core\ProxyClass\Menu\MenuActiveTrail::__construct()
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuActiveTrail.php \Drupal\Core\Menu\MenuActiveTrail::__construct()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuActiveTrail.php \Drupal\Core\Menu\MenuActiveTrail::__construct()
  3. 10 core/lib/Drupal/Core/ProxyClass/Menu/MenuActiveTrail.php \Drupal\Core\ProxyClass\Menu\MenuActiveTrail::__construct()
  4. 10 core/lib/Drupal/Core/Menu/MenuActiveTrail.php \Drupal\Core\Menu\MenuActiveTrail::__construct()

Constructs a \Drupal\Core\Menu\MenuActiveTrail object.

Parameters

\Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager: The menu link plugin manager.

\Drupal\Core\Routing\RouteMatchInterface $route_match: A route match object for finding the active link.

\Drupal\Core\Cache\CacheBackendInterface $cache: The cache backend.

\Drupal\Core\Lock\LockBackendInterface $lock: The lock backend.

\Drupal\Core\Path\PathMatcherInterface|null $pathMatcher: The path.matcher service.

Overrides CacheCollector::__construct

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMatchInterface $route_match, CacheBackendInterface $cache, LockBackendInterface $lock, protected ?PathMatcherInterface $pathMatcher = NULL) {
  parent::__construct(NULL, $cache, $lock);
  $this->menuLinkManager = $menu_link_manager;
  $this->routeMatch = $route_match;
  if ($this->pathMatcher === NULL) {
    @trigger_error('Calling ' . __METHOD__ . ' without the $pathMatcher argument is deprecated in drupal:11.2.0 and it will be required in drupal:12.0.0. See https://www.drupal.org/node/3523495', E_USER_DEPRECATED);
    $this->pathMatcher = \Drupal::service('path.matcher');
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.