public function LocalTaskDefault::getRouteParameters in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Menu/LocalTaskDefault.php \Drupal\Core\Menu\LocalTaskDefault::getRouteParameters()
- 10 core/lib/Drupal/Core/Menu/LocalTaskDefault.php \Drupal\Core\Menu\LocalTaskDefault::getRouteParameters()
Returns the route parameters needed to render a link for the local task.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
array An array of parameter names and values.
Overrides LocalTaskInterface::getRouteParameters
1 method overrides LocalTaskDefault::getRouteParameters()
- UserTrackerTab::getRouteParameters in core/
modules/ tracker/ src/ Plugin/ Menu/ UserTrackerTab.php - Returns the route parameters needed to render a link for the local task.
File
- core/
lib/ Drupal/ Core/ Menu/ LocalTaskDefault.php, line 43
Class
- LocalTaskDefault
- Default object used for LocalTaskPlugins.
Namespace
Drupal\Core\MenuCode
public function getRouteParameters(RouteMatchInterface $route_match) {
$route_parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
$route = $this
->routeProvider()
->getRouteByName($this
->getRouteName());
$variables = $route
->compile()
->getVariables();
// Normally the \Drupal\Core\ParamConverter\ParamConverterManager has
// run, and the route parameters have been upcast. The original values can
// be retrieved from the raw parameters. For example, if the route's path is
// /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
// $raw_parameters->get('filter_format') == 'plain_text'. Parameters that
// are not represented in the route path as slugs might be added by a route
// enhancer and will not be present in the raw parameters.
$raw_parameters = $route_match
->getRawParameters();
$parameters = $route_match
->getParameters();
foreach ($variables as $name) {
if (isset($route_parameters[$name])) {
continue;
}
if ($raw_parameters
->has($name)) {
$route_parameters[$name] = $raw_parameters
->get($name);
}
elseif ($parameters
->has($name)) {
$route_parameters[$name] = $parameters
->get($name);
}
}
// The UrlGenerator will throw an exception if expected parameters are
// missing. This method should be overridden if that is possible.
return $route_parameters;
}