Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Link.php \Drupal\Core\Link::createFromRoute()
  2. 9 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

18 calls to Link::createFromRoute()
announcements_feed_help in core/modules/announcements_feed/announcements_feed.module
Implements hook_help().
BookBreadcrumbBuilder::build in core/modules/book/src/BookBreadcrumbBuilder.php
Builds the breadcrumb.
CommentBreadcrumbBuilder::build in core/modules/comment/src/CommentBreadcrumbBuilder.php
Builds the breadcrumb.
EntityLinkTest::testToLink in core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php
Tests for the Entity::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));
}