You are here

public function MenuTreeStorage::loadByRoute in Colossal Menu 8

Same name and namespace in other branches
  1. 2.x src/Menu/MenuTreeStorage.php \Drupal\colossal_menu\Menu\MenuTreeStorage::loadByRoute()

Loads multiple plugin definitions from the storage based on route.

Parameters

string $route_name: The route name.

array $route_parameters: (optional) The route parameters. Defaults to an empty array.

string $menu_name: (optional) Restricts the found links to just those in the named menu.

Return value

array An array of menu link definitions keyed by ID and ordered by depth.

Overrides MenuTreeStorageInterface::loadByRoute

File

src/Menu/MenuTreeStorage.php, line 118

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\colossal_menu\Menu

Code

public function loadByRoute($route_name, array $route_parameters = [], $menu_name = NULL) {
  $url = new Url($route_name, $route_parameters);
  $query = $this->storage
    ->getQuery();
  $query
    ->condition('link__uri', $url
    ->getUri());
  if ($menu_name) {
    $query
      ->condition('menu', $menu_name);
  }
  return $query
    ->execute();
}