function TestTitleClosureAttributesPhp85::titleClosure

Two routes on one method, each with its own title closure.

Attributes

#[Route(path: '/test_title_closure/{parameter}', name: 'router_test.title_closure', title: static function (string $parameter) { return new TranslatableMarkup('First title for @parameter', [ '@parameter' => $parameter, ]); }, requirements: [ '_access' => 'TRUE', ])] #[Route(path: '/test_title_closure-other-path/{parameter}', name: 'router_test.title_closure_other', title: static function (string $parameter) { return new TranslatableMarkup('Second title for @parameter', [ '@parameter' => $parameter, ]); }, requirements: [ '_access' => 'TRUE', ])]

File

core/modules/system/tests/modules/router_test_directory/src/TestTitleClosureAttributesPhp85.php, line 19

Class

TestTitleClosureAttributesPhp85
Test controller for PHP 8.5 title closures in Route attributes.

Namespace

Drupal\router_test\Controller

Code

public function titleClosure(string $parameter) : array {
  return [
    '#markup' => 'Testing method with title closures',
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.