mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
[TASK] Bugfixes and improvements
- Most routes now works along with getRoute() method.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user