W3cubDocs

/Drupal 8

public static function Url::fromRoute

public static Url::fromRoute($route_name, $route_parameters = array(), $options = array())

Creates a new Url object for a URL that has a Drupal route.

This method is for URLs that have Drupal routes (that is, most pages generated by Drupal). For non-routed local URIs relative to the base path (like robots.txt) use Url::fromUri() with the base: scheme.

Parameters

string $route_name: The name of the route

array $route_parameters: (optional) An associative array of route parameter names and values.

array $options: See \Drupal\Core\Url::fromUri() for details.

Return value

\Drupal\Core\Url A new Url object for a routed (internal to Drupal) URL.

See also

\Drupal\Core\Url::fromUserInput()

\Drupal\Core\Url::fromUri()

File

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

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public static function fromRoute($route_name, $route_parameters = array(), $options = array()) {
  return new static($route_name, $route_parameters, $options);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Url.php/function/Url::fromRoute/8.1.x