mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-23 19:49:15 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f528c133b | |||
| 1a9351c690 | |||
| 5a50190293 | |||
| f98e5ac59d | |||
| a2dbf4149b |
@@ -123,7 +123,7 @@ class Input {
|
||||
|
||||
$postVars = array();
|
||||
|
||||
if(in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH', 'DELETE'])) {
|
||||
if(isset($_SERVER['REQUEST_METHOD']) && in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH', 'DELETE'])) {
|
||||
parse_str(file_get_contents('php://input'), $postVars);
|
||||
} else {
|
||||
$postVars = $_POST;
|
||||
|
||||
@@ -22,9 +22,9 @@ class Request {
|
||||
|
||||
public function __construct() {
|
||||
$this->data = array();
|
||||
$this->host = $_SERVER['HTTP_HOST'];
|
||||
$this->uri = $_SERVER['REQUEST_URI'];
|
||||
$this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : strtolower($_SERVER['REQUEST_METHOD']);
|
||||
$this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : array();
|
||||
$this->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : array();
|
||||
$this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : (isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : array());
|
||||
$this->headers = $this->getAllHeaders();
|
||||
$this->input = new Input();
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ class RouterBase {
|
||||
$route->renderRoute($this->request);
|
||||
$mergedSettings = array_merge($settings, $route->getMergeableSettings());
|
||||
|
||||
// Add exceptionhandler
|
||||
// Add ExceptionHandler
|
||||
if($route->matchRoute($this->request) && $route->getExceptionHandler() !== null) {
|
||||
$this->exceptionHandlers[] = $route->getExceptionHandler();
|
||||
$this->exceptionHandlers[] = $route;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,8 +178,12 @@ class RouterBase {
|
||||
|
||||
protected function handleException(\Exception $e) {
|
||||
|
||||
foreach ($this->exceptionHandlers as $handler) {
|
||||
$handler = new $handler($this->request);
|
||||
/* @var $route RouterEntry */
|
||||
foreach ($this->exceptionHandlers as $route) {
|
||||
$route->loadMiddleware($this->request);
|
||||
$handler = $route->getExceptionHandler();
|
||||
$handler = new $handler();
|
||||
|
||||
if (!($handler instanceof IExceptionHandler)) {
|
||||
throw new RouterException('Exception handler must implement the IExceptionHandler interface.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user