Loading core/lib/Drupal/Core/Controller/TitleResolver.php +4 −3 Original line number Diff line number Diff line Loading @@ -57,10 +57,11 @@ public function getTitle(Request $request, Route $route) { $arguments = $this->argumentResolver->getArguments($request, $callable); $route_title = call_user_func_array($callable, $arguments); } elseif ($title = $route->getDefault('_title')) { elseif ($route->hasDefault('_title') && strlen($route->getDefault('_title')) > 0) { $title = $route->getDefault('_title'); $options = []; if ($context = $route->getDefault('_title_context')) { $options['context'] = $context; if ($route->hasDefault('_title_context')) { $options['context'] = $route->getDefault('_title_context'); } $args = []; if (($raw_parameters = $request->attributes->get('_raw_variables'))) { Loading core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php +11 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,17 @@ public function testStaticTitle() { $this->assertEquals(new TranslatableMarkup('static title', [], [], $this->translationManager), $this->titleResolver->getTitle($request, $route)); } /** * Tests a static title of '0'. * * @see \Drupal\Core\Controller\TitleResolver::getTitle() */ public function testStaticTitleZero() { $request = new Request(); $route = new Route('/test-route', ['_title' => '0', '_title_context' => '0']); $this->assertEquals(new TranslatableMarkup('0', [], ['context' => '0'], $this->translationManager), $this->titleResolver->getTitle($request, $route)); } /** * Tests a static title with a context. * Loading Loading
core/lib/Drupal/Core/Controller/TitleResolver.php +4 −3 Original line number Diff line number Diff line Loading @@ -57,10 +57,11 @@ public function getTitle(Request $request, Route $route) { $arguments = $this->argumentResolver->getArguments($request, $callable); $route_title = call_user_func_array($callable, $arguments); } elseif ($title = $route->getDefault('_title')) { elseif ($route->hasDefault('_title') && strlen($route->getDefault('_title')) > 0) { $title = $route->getDefault('_title'); $options = []; if ($context = $route->getDefault('_title_context')) { $options['context'] = $context; if ($route->hasDefault('_title_context')) { $options['context'] = $route->getDefault('_title_context'); } $args = []; if (($raw_parameters = $request->attributes->get('_raw_variables'))) { Loading
core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php +11 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,17 @@ public function testStaticTitle() { $this->assertEquals(new TranslatableMarkup('static title', [], [], $this->translationManager), $this->titleResolver->getTitle($request, $route)); } /** * Tests a static title of '0'. * * @see \Drupal\Core\Controller\TitleResolver::getTitle() */ public function testStaticTitleZero() { $request = new Request(); $route = new Route('/test-route', ['_title' => '0', '_title_context' => '0']); $this->assertEquals(new TranslatableMarkup('0', [], ['context' => '0'], $this->translationManager), $this->titleResolver->getTitle($request, $route)); } /** * Tests a static title with a context. * Loading