[FEATURE]

- Added RouterController class.
- Added Router::controller functionality to SimpleRouter class.
- Bugfixes and optimisations.
This commit is contained in:
Simon Sessingø
2015-09-22 13:39:17 +02:00
parent 6b8ab11f28
commit 67c3479a3e
6 changed files with 223 additions and 35 deletions
+26
View File
@@ -4,8 +4,11 @@ namespace Pecee\SimpleRouter;
class RouterGroup extends RouterEntry {
protected $requestTypes;
public function __construct() {
parent::__construct();
$this->requestTypes = array();
}
public function getRoute($requestMethod, &$url) {
@@ -18,4 +21,27 @@ class RouterGroup extends RouterEntry {
return null;
}
/**
* Add request type
*
* @param $type
* @return self
* @throws RouterException
*/
public function addRequestType($type) {
if(!in_array($type, self::$allowedRequestTypes)) {
throw new RouterException('Invalid request method: ' . $type);
}
$this->requestTypes[] = $type;
return $this;
}
/**
* @return mixed
*/
public function getRequestTypes() {
return $this->requestTypes;
}
}