function Route::__construct

Same name in this branch
  1. 11.x core/modules/migrate/src/Plugin/migrate/process/Route.php \Drupal\migrate\Plugin\migrate\process\Route::__construct()
Same name and namespace in other branches
  1. 10 core/modules/migrate/src/Plugin/migrate/process/Route.php \Drupal\migrate\Plugin\migrate\process\Route::__construct()
  2. 9 core/modules/migrate/src/Plugin/migrate/process/Route.php \Drupal\migrate\Plugin\migrate\process\Route::__construct()
  3. 8.9.x core/modules/migrate/src/Plugin/migrate/process/Route.php \Drupal\migrate\Plugin\migrate\process\Route::__construct()

Constructs a Route attribute.

Parameters

string|array<string,string>|null $path: The route path (i.e. "/user/login").

string|null $name: The route name (i.e. "user.login").

array<string|\Stringable> $requirements: Requirements for the route attributes.

array<string, mixed> $options: Options for the route (i.e. ['_admin_route' => TRUE]).

array<string, mixed> $defaults: Default values for the route attributes and query parameters.

string|null $host: The host for which this route should be active.

string|string[] $methods: The list of HTTP methods allowed by this route.

string|string[] $schemes: The list of schemes allowed by this route (i.e. "https").

string|null $condition: An expression that must evaluate to true for the route to be matched.

int|null $priority: The priority of the route if multiple ones are defined for the same path.

string|null $locale: The locale accepted by the route.

string|null $format: The format returned by the route (i.e. "json", "xml").

bool|null $utf8: Whether the route accepts UTF-8 in its parameters.

bool|null $stateless: Whether the route is defined as stateless or stateful.

string|string[]|null $env: The env(s) in which the route is defined.

string|\Symfony\Component\Routing\Attribute\DeprecatedAlias|array<string|\Symfony\Component\Routing\Attribute\DeprecatedAlias> $alias: The list of aliases for this route.

string|\Stringable|\Closure|null $title: The page title for the route. This is a convenience for setting the "_title" default. A closure may be used to calculate the title when the page is rendered.

File

core/lib/Drupal/Core/Routing/Attribute/Route.php, line 91

Class

Route
Adds Drupal-specific properties to the Symfony Route attribute.

Namespace

Drupal\Core\Routing\Attribute

Code

public function __construct(string|array|null $path = NULL, ?string $name = NULL, array $requirements = [], array $options = [], array $defaults = [], ?string $host = NULL, array|string $methods = [], array|string $schemes = [], ?string $condition = NULL, ?int $priority = NULL, ?string $locale = NULL, ?string $format = NULL, ?bool $utf8 = NULL, ?bool $stateless = NULL, string|array|null $env = NULL, string|DeprecatedAlias|array $alias = [], string|\Stringable|\Closure|null $title = NULL) {
  parent::__construct($path, $name, $requirements, $options, $defaults, $host, $methods, $schemes, $condition, $priority, $locale, $format, $utf8, $stateless, $env, $alias);
  if ($title !== NULL) {
    assert(!array_key_exists('_title', $this->defaults), 'The "title" property cannot be used together with a "_title" default on the Route attribute.');
    $this->defaults['_title'] = $title;
  }
}

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