Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Url.php

function Url::fromRoute

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

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

See also

\Drupal\Core\Url::fromUserInput()

\Drupal\Core\Url::fromUri()

136 calls to Url::fromRoute()
AccessDeniedSubscriber::on403 in core/modules/user/src/EventSubscriber/AccessDeniedSubscriber.php
Redirects users when access is denied.
authorize.php in core/authorize.php
Administrative script for running authorized file operations.
BanAdmin::buildForm in core/modules/ban/src/Form/BanAdmin.php
batch_process in core/includes/form.inc
Processes the batch.
BlockHooks::pageTop in core/modules/block/src/Hook/BlockHooks.php
Implements hook_page_top().

... See full list

File

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

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public static function fromRoute($route_name, $route_parameters = [], $options = []) {
    return new static($route_name, $route_parameters, $options);
}
RSS feed
Powered by Drupal