[TASK] Moved parameter stuff to RouterEntry class.

This commit is contained in:
Simon Sessingø
2015-10-14 20:48:17 +02:00
parent 93d8c26416
commit b6f0f6899a
2 changed files with 31 additions and 31 deletions
+31
View File
@@ -18,9 +18,13 @@ abstract class RouterEntry {
protected $settings; protected $settings;
protected $callback; protected $callback;
protected $parameters;
protected $parametersRegex;
public function __construct() { public function __construct() {
$this->settings = array(); $this->settings = array();
$this->parameters = array();
$this->parametersRegex = array();
} }
protected function loadClass($name) { protected function loadClass($name) {
@@ -116,6 +120,33 @@ abstract class RouterEntry {
return $this->settings; return $this->settings;
} }
/**
* @return mixed
*/
public function getParameters(){
return $this->parameters;
}
/**
* @param mixed $parameters
* @return self
*/
public function setParameters($parameters) {
$this->parameters = $parameters;
return $this;
}
/**
* Add regular expression parameter match
*
* @param array $options
* @return self
*/
public function where(array $options) {
$this->parametersRegex = array_merge($this->parametersRegex, $options);
return $this;
}
/** /**
* Get settings that are allowed to be inherited by child routes. * Get settings that are allowed to be inherited by child routes.
* *
-31
View File
@@ -9,8 +9,6 @@ class RouterRoute extends RouterEntry {
protected $url; protected $url;
protected $requestTypes; protected $requestTypes;
protected $parameters;
protected $parametersRegex;
public function __construct($url, $callback) { public function __construct($url, $callback) {
parent::__construct(); parent::__construct();
@@ -19,8 +17,6 @@ class RouterRoute extends RouterEntry {
$this->settings['aliases'] = array(); $this->settings['aliases'] = array();
$this->requestTypes = array(); $this->requestTypes = array();
$this->parameters = array();
$this->parametersRegex = array();
} }
protected function parseParameters($url) { protected function parseParameters($url) {
@@ -178,31 +174,4 @@ class RouterRoute extends RouterEntry {
public function getRequestTypes() { public function getRequestTypes() {
return $this->requestTypes; return $this->requestTypes;
} }
/**
* @return mixed
*/
public function getParameters(){
return $this->parameters;
}
/**
* @param mixed $parameters
* @return self
*/
public function setParameters($parameters) {
$this->parameters = $parameters;
return $this;
}
/**
* Add regular expression parameter match
*
* @param array $options
* @return self
*/
public function where(array $options) {
$this->parametersRegex = array_merge($this->parametersRegex, $options);
return $this;
}
} }