8.5.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = [], $options = [])
8.0.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = array(), $options = array())
8.1.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = array(), $options = array())
8.2.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = array(), $options = array())
8.3.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = [], $options = [])
8.4.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = [], $options = [])
8.6.x UrlGeneratorTrait.php UrlGeneratorTrait::url($route_name, $route_parameters = [], $options = [])

Generates a URL or path for a specific route based on the given parameters.

For details on the arguments, usage, and possible exceptions see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute().

Return value

string The generated URL for the given route.

Deprecated

in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Url instead.

See also

\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()

36 calls to UrlGeneratorTrait::url()
AccountForm::form in core/modules/user/src/AccountForm.php
Gets the actual form array to be built.
AccountSettingsForm::buildForm in core/modules/user/src/AccountSettingsForm.php
Form constructor.
AggregatorController::adminOverview in core/modules/aggregator/src/Controller/AggregatorController.php
Displays the aggregator administration page.
BlockContentAddLocalAction::getOptions in core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php
Returns options for rendering a link for the local action.
CommentForm::form in core/modules/comment/src/CommentForm.php
Gets the actual form array to be built.

... See full list

File

core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 41

Class

UrlGeneratorTrait
Wrapper methods for the Url Generator.

Namespace

Drupal\Core\Routing

Code

protected function url($route_name, $route_parameters = array(), $options = array()) {
  return $this
    ->getUrlGenerator()
    ->generateFromRoute($route_name, $route_parameters, $options);
}