public TwigExtension::getUrl($name, $parameters = array(), $options = array())
Generates an absolute URL given a route name and parameters.
@todo Add an option for scheme-relative URLs.
$name: The name of the route.
array $parameters: An associative array of route parameter names and values.
array $options: (optional) An associative array of additional options. The 'absolute' option is forced to be TRUE.
string The generated absolute URL for the given route.
public function getUrl($name, $parameters = array(), $options = array()) { // Generate URL. $options['absolute'] = TRUE; $generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE); // Return as render array, so we can bubble the bubbleable metadata. $build = ['#markup' => $generated_url->getGeneratedUrl()]; $generated_url->applyTo($build); return $build; }
© 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!Core!Template!TwigExtension.php/function/TwigExtension::getUrl/8.1.x