Browse Source

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

3.1.x
kristiaanvandeneynde 3 years ago committed by Chi
parent
commit
f05e278611
  1. 10
      src/TwigTweakExtension.php

10
src/TwigTweakExtension.php

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

Loading…
Cancel
Save