function TwigExtension::getPath
Same name in other branches
- 9 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getPath()
- 8.9.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getPath()
- 10 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getPath()
Generates a URL path given a route name and parameters.
Parameters
$name: The name of the route.
array $parameters: (optional) An associative array of route parameters names and values.
array $options: (optional) An associative array of additional options. The 'absolute' option is forced to be FALSE.
Return value
string The generated URL path (relative URL) for the given route.
See also
\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
File
-
core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 199
Class
- TwigExtension
- A class providing Drupal Twig extensions.
Namespace
Drupal\Core\TemplateCode
public function getPath($name, $parameters = [], $options = []) {
assert($this->urlGenerator instanceof UrlGeneratorInterface, "The URL generator hasn't been set up. Any configuration YAML file with a service directive dealing with the Twig configuration can cause this, most likely found in a recently installed or changed module.");
$options['absolute'] = FALSE;
return $this->urlGenerator
->generateFromRoute($name, $parameters, $options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.