Commit e40be42b authored by catch's avatar catch
Browse files

Issue #3344744 by alexpott: A route with a default title of 0 does not work

(cherry picked from commit 1ab5db03)
parent f76bfd35
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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'))) {
+11 −0
Original line number Diff line number Diff line
@@ -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.
   *