protected static function Url::fromRouteUri in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::fromRouteUri()
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
static A new Url object for a 'route:' URI.
Throws
\InvalidArgumentException Thrown when the route URI does not have a route name.
1 call to Url::fromRouteUri()
- Url::fromUri in core/
lib/ Drupal/ Core/ Url.php - Creates a new Url object from a URI.
File
- core/
lib/ Drupal/ Core/ Url.php, line 449
Class
- Url
- Defines an object that holds information about a URL.
Namespace
Drupal\CoreCode
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);
}