You are here

public static function Url::fromRoute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Url.php \Drupal\Core\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: (optional) An associative array of additional URL options, with the following elements:

  • 'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL. Merged with the parameters array.
  • 'fragment': A fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.
  • 'absolute': Defaults to FALSE. Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
  • 'language': An optional language object used to look up the alias for the URL. If $options['language'] is omitted, it defaults to the current language for the language type LanguageInterface::TYPE_URL.
  • 'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP.

Return value

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

See also

\Drupal\Core\Url::fromUserInput()

\Drupal\Core\Url::fromUri()

188 calls to Url::fromRoute()
AggregatorController::adminOverview in core/modules/aggregator/src/Controller/AggregatorController.php
Displays the aggregator administration page.
AjaxFormCacheTest::testFormCacheUsage in core/modules/system/src/Tests/Ajax/AjaxFormCacheTest.php
Tests the usage of form cache for AJAX forms.
AjaxFormCacheTest::testQueryString in core/modules/system/src/Tests/Ajax/AjaxFormCacheTest.php
Tests AJAX forms on pages with a query string.
AjaxTestController::dialog in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
Returns a render array of form elements and links for dialog.
AjaxTestController::dialogContents in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
Example content for dialog testing.

... See full list

File

core/lib/Drupal/Core/Url.php, line 171
Contains \Drupal\Core\Url.

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public static function fromRoute($route_name, $route_parameters = array(), $options = array()) {
  return new static($route_name, $route_parameters, $options);
}