You are here

public static function Link::createFromRoute in Drupal 9

Same name and namespace in other branches
  1. 8 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

19 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 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 73

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));
}