W3cubDocs

/Drupal 8

public static function Drupal::l

public static Drupal::l($text, Url $url)

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. For detailed documentation, see \Drupal\Core\Routing\LinkGeneratorInterface::generate().

Parameters

string $text: The link text for the anchor tag.

\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 will be removed before Drupal 9.0.0. Use \Drupal\Core\Link instead. Example:

    $link = Link::fromTextAndUrl($text, $url);
  

See also

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

\Drupal\Core\Url

File

core/lib/Drupal.php, line 581
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

public static function l($text, Url $url) {
  return static::getContainer()->get('link_generator')->generate($text, $url);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal::l/8.1.x