Browse Source

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

merge-requests/12/head
kristiaanvandeneynde 3 years ago committed by Chi
parent
commit
f51df921a0
  1. 8
      src/TwigExtension.php

8
src/TwigExtension.php

@ -888,10 +888,10 @@ class TwigExtension extends AbstractExtension {
* A render array to represent page title.
*/
public function drupalTitle() {
$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