Browse Source

Issue #3245953 by kristiaanvandeneynde: TwigExtension::drupalTitle() should check for NullRouteMatch

merge-requests/14/head
kristiaanvandeneynde 3 years ago committed by Chi
parent
commit
7a8e01b9b9
  1. 10
      src/TwigTweakExtension.php

10
src/TwigTweakExtension.php

@ -314,12 +314,14 @@ class TwigTweakExtension extends AbstractExtension {
/**
* Returns a title for the current route.
*
* @todo Test it with NullRouteMatch
*/
public static function drupalTitle(): array {
$title = \Drupal::service('title_resolver')->getTitle(
\Drupal::request(),
\Drupal::routeMatch()->getRouteObject()
);
$title = NULL;
if ($route = \Drupal::routeMatch()->getRouteObject()) {
$title = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route);
}
$build['#markup'] = render($title);
$build['#cache']['contexts'] = ['url'];
return $build;

Loading…
Cancel
Save