You are here

public static function Drupal::url in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal.php \Drupal::url()

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()

\Drupal\Core\Url

\Drupal\Core\Url::fromRoute()

\Drupal\Core\Url::fromUri()

165 calls to Drupal::url()
action_help in core/modules/action/action.module
Implements hook_help().
AddFeedTest::testAddFeed in core/modules/aggregator/src/Tests/AddFeedTest.php
Creates and ensures that a feed is unique, checks source, and deletes feed.
AggregatorTestBase::getFeedEditArray in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Returns a randomly generated feed edit array.
AggregatorTestBase::getFeedEditObject in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Returns a randomly generated feed edit object.
aggregator_help in core/modules/aggregator/aggregator.module
Implements hook_help().

... See full list

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