mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
[TASK] Moved parameter stuff to RouterEntry class.
This commit is contained in:
@@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user