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.
Parameters
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.
Return value
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.
Deprecated
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().
See also
\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
File
- core/lib/Drupal.php, line 542
- Contains \Drupal.
Class
- Drupal
- Static Service Container wrapper.
Code
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); }
Please login to continue.