[TASK] Bugfixes and improvements

- Most routes now works along with getRoute() method.
This commit is contained in:
Simon Sessingø
2015-10-06 16:08:42 +02:00
parent 1c765476b5
commit 6354c3c766
6 changed files with 160 additions and 132 deletions
+3 -28
View File
@@ -4,16 +4,14 @@ namespace Pecee\SimpleRouter;
class RouterGroup extends RouterEntry {
protected $requestTypes;
public function __construct() {
parent::__construct();
$this->requestTypes = array();
}
public function getRoute($requestMethod, &$url) {
public function matchRoute($requestMethod, $url) {
// Check if request method is allowed
if(count($this->requestTypes) === 0 || in_array($requestMethod, $this->requestTypes)) {
if(count($this->method) === 0 || strtolower($this->method) == strtolower($requestMethod) || is_array($this->method) && in_array($this->method, self::$allowedRequestTypes)) {
return $this;
}
@@ -21,27 +19,4 @@ 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;
}
}