function Drupal::l

Renders a link with a given link text and Url object.

This method is a convenience wrapper for the link generator service's generate() method.

Parameters

string|array|\Drupal\Component\Render\MarkupInterface $text: The link text for the anchor tag as a translated string or render array.

\Drupal\Core\Url $url: The URL object used for the link.

Return value

\Drupal\Core\GeneratedLink A GeneratedLink object containing a link to the given route and parameters and bubbleable metadata.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead.

See also

https://www.drupal.org/node/2614344

\Drupal\Core\Utility\LinkGeneratorInterface::generate()

\Drupal\Core\Url

1 call to Drupal::l()
DrupalTest::testL in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the l() method.

File

core/lib/Drupal.php, line 625

Class

Drupal
Static Service Container wrapper.

Code

public static function l($text, Url $url) {
    @trigger_error('\\Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
    return static::getContainer()->get('link_generator')
        ->generate($text, $url);
}

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