public function MenuLinkManager::loadLinksByRoute in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::loadLinksByRoute()
Loads multiple plugin instances 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
\Drupal\Core\Menu\MenuLinkInterface[] An array of instances keyed by plugin ID.
Overrides MenuLinkManagerInterface::loadLinksByRoute
File
- core/
lib/ Drupal/ Core/ Menu/ MenuLinkManager.php, line 334
Class
- MenuLinkManager
- Manages discovery, instantiation, and tree building of menu link plugins.
Namespace
Drupal\Core\MenuCode
public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL) {
$instances = [];
$loaded = $this->treeStorage
->loadByRoute($route_name, $route_parameters, $menu_name);
foreach ($loaded as $plugin_id => $definition) {
$instances[$plugin_id] = $this
->createInstance($plugin_id);
}
return $instances;
}