public function Route::__construct

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

Constructor.

Parameters

array $data An array of key/value parameters.:

File

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

Class

Route
Annotation class for @Route().

Namespace

Symfony\Component\Routing\Annotation

Code

public function __construct(array $data) {
  $this->requirements = array();
  $this->options = array();
  $this->defaults = array();
  if (isset($data['value'])) {
    $data['pattern'] = $data['value'];
    unset($data['value']);
  }
  foreach ($data as $key => $value) {
    $method = 'set' . $key;
    if (!method_exists($this, $method)) {
      throw new \BadMethodCallException(sprintf("Unknown property '%s' on annotation '%s'.", $key, get_class($this)));
    }
    $this
      ->{$method}($value);
  }
}