Cake\Routing\Route\Route::__construct PHP Method

__construct() public method

### Options - _ext - Defines the extensions used for this route. - pass - Copies the listed parameters into params['pass'].
public __construct ( string $template, array | string $defaults = [], array $options = [] )
$template string Template string with parameter placeholders
$defaults array | string Defaults for the route.
$options array Array of additional options for the Route
    public function __construct($template, $defaults = [], array $options = [])
    {
        $this->template = $template;
        $this->defaults = (array) $defaults;
        if (isset($this->defaults['[method]'])) {
            $this->defaults['_method'] = $this->defaults['[method]'];
            unset($this->defaults['[method]']);
        }
        $this->options = $options + ['_ext' => []];
        $this->setExtensions((array) $this->options['_ext']);
    }

Usage Example

Example #1
0
 /**
  * Constructor
  *
  * @param string $template Template string with parameter placeholders
  * @param array|string $defaults Defaults for the route.
  * @param array $options Array of additional options for the Route
  */
 public function __construct($template, $defaults = [], array $options = [])
 {
     parent::__construct($template, $defaults, $options);
     if (is_array($defaults) && isset($defaults['redirect'])) {
         $defaults = $defaults['redirect'];
     }
     $this->redirect = (array) $defaults;
 }
All Usage Examples Of Cake\Routing\Route\Route::__construct