You are here

protected static function Url::fromRouteUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 static::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.

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 460
Contains \Drupal\Core\Url.

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);
}