You are here

protected function RouteMatch::getParameterNames in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Routing/RouteMatch.php \Drupal\Core\Routing\RouteMatch::getParameterNames()

Returns the names of all parameters for the currently matched route.

Return value

array Route parameter names as both the keys and values.

1 call to RouteMatch::getParameterNames()
RouteMatch::__construct in core/lib/Drupal/Core/Routing/RouteMatch.php
Constructs a RouteMatch object.

File

core/lib/Drupal/Core/Routing/RouteMatch.php, line 148
Contains \Drupal\Core\Routing\RouteMatch.

Class

RouteMatch
Default object representing the results of routing.

Namespace

Drupal\Core\Routing

Code

protected function getParameterNames() {
  $names = array();
  if ($route = $this
    ->getRouteObject()) {

    // Variables defined in path and host patterns are route parameters.
    $variables = $route
      ->compile()
      ->getVariables();
    $names = array_combine($variables, $variables);

    // Route defaults that do not start with a leading "_" are also
    // parameters, even if they are not included in path or host patterns.
    foreach ($route
      ->getDefaults() as $name => $value) {
      if (!isset($names[$name]) && substr($name, 0, 1) !== '_') {
        $names[$name] = $name;
      }
    }
  }
  return $names;
}