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);
}
doc_Drupal
2016-10-29 09:02:47
Comments
Leave a Comment

Please login to continue.