public static Drupal::url($route_name, $route_parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE)
Generates a URL string for a specific route based on the given parameters.
This method is a convenience wrapper for generating URL strings for URLs that have Drupal routes (that is, most pages generated by Drupal) using the \Drupal\Core\Url object. See \Drupal\Core\Url::fromRoute() for detailed documentation. For non-routed local URIs relative to the base path (like robots.txt) use Url::fromUri()->toString() with the base: scheme.
string $route_name: The name of the route.
array $route_parameters: (optional) An associative array of parameter names and values.
array $options: (optional) An associative array of additional options.
bool $collect_bubbleable_metadata: (optional) Defaults to FALSE. When TRUE, both the generated URL and its associated bubbleable metadata are returned.
string|\Drupal\Core\GeneratedUrl A string containing a URL to the given path. When $collect_bubbleable_metadata is TRUE, a GeneratedUrl object is returned, containing the generated URL plus bubbleable metadata.
as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute().
\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
public static function url($route_name, $route_parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) { return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata); }
© 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.php/function/Drupal::url/8.1.x