function Link::createFromRoute

Same name in other branches
  1. 9 core/lib/Drupal/Core/Link.php \Drupal\Core\Link::createFromRoute()
  2. 8.9.x core/lib/Drupal/Core/Link.php \Drupal\Core\Link::createFromRoute()
  3. 10 core/lib/Drupal/Core/Link.php \Drupal\Core\Link::createFromRoute()

Creates a Link object from a given route name and parameters.

Parameters

string|array|\Drupal\Component\Render\MarkupInterface $text: The link text for the anchor tag as a translated string or render array. Strings will be sanitized automatically. If you need to output HTML in the link text, use a render array or an already sanitized string such as the output of \Drupal\Component\Utility\Xss::filter() or \Drupal\Component\Render\FormattableMarkup.

string $route_name: The name of the route

array $route_parameters: (optional) An associative array of parameter names and values.

array $options: The options parameter takes exactly the same structure. See \Drupal\Core\Url::fromUri() for details.

Return value

static

21 calls to Link::createFromRoute()
BookBreadcrumbBuilder::build in core/modules/book/src/BookBreadcrumbBuilder.php
Builds the breadcrumb.
CommentBreadcrumbBuilder::build in core/modules/comment/src/CommentBreadcrumbBuilder.php
Builds the breadcrumb.
EntityController::addPage in core/lib/Drupal/Core/Entity/Controller/EntityController.php
Displays add links for the available bundles.
EntityLinkTest::testToLink in core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php
Tests for the EntityBase::toLink() method.
ForumBreadcrumbBuilderBase::build in core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php
Builds the breadcrumb.

... See full list

File

core/lib/Drupal/Core/Link.php, line 75

Class

Link
Defines an object that holds information about a link.

Namespace

Drupal\Core

Code

public static function createFromRoute($text, $route_name, $route_parameters = [], $options = []) {
    return new static($text, new Url($route_name, $route_parameters, $options));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.