function Link::fromTextAndUrl

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Link.php \Drupal\Core\Link::fromTextAndUrl()
  2. 8.9.x core/lib/Drupal/Core/Link.php \Drupal\Core\Link::fromTextAndUrl()
  3. 11.x core/lib/Drupal/Core/Link.php \Drupal\Core\Link::fromTextAndUrl()

Creates a Link object from a given Url object.

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.

\Drupal\Core\Url $url: The Url to create the link for.

Return value

static

2 calls to Link::fromTextAndUrl()
LinkGeneratorTest::testGenerateTwice in core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
Tests whether rendering the same link twice works.
TestHelpSection::listTopics in core/modules/help/tests/modules/help_topics_test/src/Plugin/HelpSection/TestHelpSection.php
Returns a list of topics to show in the help section.

File

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

Class

Link
Defines an object that holds information about a link.

Namespace

Drupal\Core

Code

public static function fromTextAndUrl($text, Url $url) {
  return new static($text, $url);
}

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