mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-15 18:23:26 +03:00
Bugfixes
This commit is contained in:
@@ -37,6 +37,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||
$middleware = $this->getMiddlewares()[$i];
|
||||
|
||||
$middleware = $this->loadClass($middleware);
|
||||
|
||||
if (!($middleware instanceof IMiddleware)) {
|
||||
throw new HttpException($middleware . ' must be instance of Middleware');
|
||||
}
|
||||
@@ -60,7 +61,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||
|
||||
/* Remove global match */
|
||||
if (count($parameters) > 1) {
|
||||
$this->setParameters(array_slice($parameters, 1));
|
||||
$this->parameters = array_slice($parameters, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class Route implements IRoute
|
||||
|
||||
protected function loadClass($name)
|
||||
{
|
||||
if (!class_exists($name)) {
|
||||
if (class_exists($name) === false) {
|
||||
throw new NotFoundHttpException(sprintf('Class %s does not exist', $name), 404);
|
||||
}
|
||||
|
||||
@@ -528,7 +528,6 @@ abstract class Route implements IRoute
|
||||
* If this is the first time setting parameters we store them so we
|
||||
* later can organize the array, in case somebody tried to sort the array.
|
||||
*/
|
||||
|
||||
if(count($parameters) > 0 && count($this->originalParameters) === 0) {
|
||||
$this->originalParameters = $parameters;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class RouteController extends LoadableRoute implements IControllerRoute
|
||||
//array_shift($path);
|
||||
//$this->parameters = $path;
|
||||
|
||||
$this->setParameters(array_slice($path, 1));
|
||||
$this->parameters = array_slice($path, 1);
|
||||
|
||||
// Set callback
|
||||
$this->setCallback($this->controller . '@' . $this->method);
|
||||
|
||||
@@ -28,9 +28,7 @@ class RouteGroup extends Route implements IGroupRoute
|
||||
|
||||
if ($parameters !== null && count($parameters) > 0) {
|
||||
|
||||
$this->setParameters($parameters);
|
||||
//$this->parameters = array_merge($this->parameters, $parameters);
|
||||
|
||||
$this->parameters = $parameters;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,19 +82,19 @@ class RouteResource extends LoadableRoute implements IControllerRoute
|
||||
$url = rtrim($url, '/') . '/';
|
||||
|
||||
/* Match global regular-expression for route */
|
||||
if($this->matchRegex($request, $url) === true) {
|
||||
return true;
|
||||
$domainMatch = $this->matchRegex($request, $url);
|
||||
if($domainMatch !== null) {
|
||||
return $domainMatch;
|
||||
}
|
||||
|
||||
$route = rtrim($this->url, '/') . '/{id?}/{action?}';
|
||||
|
||||
$parameters = $this->parseParameters($route, $url);
|
||||
|
||||
if ($parameters === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setParameters((array)$parameters);
|
||||
$this->parameters = (array)$parameters;
|
||||
|
||||
$action = isset($this->parameters['action']) ? $this->parameters['action'] : null;
|
||||
unset($this->parameters['action']);
|
||||
@@ -107,7 +107,7 @@ class RouteResource extends LoadableRoute implements IControllerRoute
|
||||
}
|
||||
|
||||
// Update
|
||||
if (isset($this->parameters['id']) && in_array($method, [ static::REQUEST_TYPE_PATCH, static::REQUEST_TYPE_PUT ])) {
|
||||
if (isset($this->parameters['id']) && in_array($method, [ static::REQUEST_TYPE_PATCH, static::REQUEST_TYPE_PUT ], false)) {
|
||||
return $this->call($this->methodNames['update']);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ class RouteUrl extends LoadableRoute
|
||||
$url = rtrim($url, '/') . '/';
|
||||
|
||||
/* Match global regular-expression for route */
|
||||
if($this->matchRegex($request, $url) === true) {
|
||||
return true;
|
||||
$domainMatch = $this->matchRegex($request, $url);
|
||||
if($domainMatch !== null) {
|
||||
return $domainMatch;
|
||||
}
|
||||
|
||||
/* Make regular expression based on route */
|
||||
|
||||
Reference in New Issue
Block a user