public function Route::__construct

Same name in this branch
  1. 8.x drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php \Symfony\Component\Routing\Route::__construct()
  2. 8.x drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php \Symfony\Component\Routing\Annotation\Route::__construct()

Constructor.

Available options:

  • compiler_class: A class name able to compile this route instance (RouteCompiler by default)

@api

Parameters

string $path The path pattern to match:

array $defaults An array of default parameter values:

array $requirements An array of requirements for parameters (regexes):

array $options An array of options:

string $host The host pattern to match:

string|array $schemes A required URI scheme or an array of restricted schemes:

string|array $methods A required HTTP method or an array of restricted methods:

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php, line 81

Class

Route
A Route describes a route and its parameters.

Namespace

Symfony\Component\Routing

Code

public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array()) {
  $this
    ->setPath($path);
  $this
    ->setDefaults($defaults);
  $this
    ->setRequirements($requirements);
  $this
    ->setOptions($options);
  $this
    ->setHost($host);

  // The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement.
  // They can be removed when the BC layer is removed.
  if ($schemes) {
    $this
      ->setSchemes($schemes);
  }
  if ($methods) {
    $this
      ->setMethods($methods);
  }
}