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:
1 | $link = Link::fromTextAndUrl( $text , $url ); |
See also
\Drupal\Core\Utility\LinkGeneratorInterface::generate()
File
- core/lib/Drupal.php, line 581
- Contains \Drupal.
Class
- Drupal
- Static Service Container wrapper.
Code
1 2 3 | public static function l( $text , Url $url ) { return static ::getContainer()->get( 'link_generator' )->generate( $text , $url ); } |
Please login to continue.