Url::fromRouteUri

protected static Url::fromRouteUri(array $uri_parts, array $options, $uri)

Creates a new Url object for 'route:' URIs.

Parameters

array $uri_parts: Parts from an URI of the form route:{route_name};{route_parameters} as from parse_url(), where the path is the route name optionally followed by a ";" followed by route parameters in key=value format with & separators.

array $options: An array of options, see \Drupal\Core\Url::fromUri() for details.

string $uri: The original passed in URI.

Return value

\Drupal\Core\Url A new Url object for a 'route:' URI.

Throws

\InvalidArgumentException Thrown when the route URI does not have a route name.

File

core/lib/Drupal/Core/Url.php, line 439

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

protected static function fromRouteUri(array $uri_parts, array $options, $uri) {
  $route_parts = explode(';', $uri_parts['path'], 2);
  $route_name = $route_parts[0];
  if ($route_name === '') {
    throw new \InvalidArgumentException("The route URI '$uri' is invalid. You must have a route name in the URI. e.g., route:system.admin");
  }
  $route_parameters = [];
  if (!empty($route_parts[1])) {
    parse_str($route_parts[1], $route_parameters);
  }

  return new static($route_name, $route_parameters, $options);
}
doc_Drupal
2016-10-29 09:51:39
Comments
Leave a Comment

Please login to continue.