public static function TwigTweakExtension::drupalTitle in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::drupalTitle()
Returns a title for the current route.
File
- src/
TwigTweakExtension.php, line 316
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public static function drupalTitle() : array {
$title = \Drupal::service('title_resolver')
->getTitle(\Drupal::request(), \Drupal::routeMatch()
->getRouteObject());
$build['#markup'] = render($title);
$build['#cache']['contexts'] = [
'url',
];
return $build;
}