mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 10:40:18 +03:00
Development
- Removed temporary `RouterException` class. - Added object-types to parameters in `CallbackExceptionHandler` and `SimpleRouter` classes. - Router now renders groups even if callback is null. - Renamed `setMiddleware` to `addMiddleware` in `Route` class and `IRoute` interface. - `addMiddleware` now accept both object and class strings in `Route` class. - `addExceptionHandler` now accept both object and class strings in `RouteGroup` class. - Added unit-test for rewrite-exception message change: `testRewriteExceptionMessage` in `RouterRewriteTest`. - Fixed typo: renamed `testSimularUrls` to `testSimilarUrls` in `RouterUrlTest`.
This commit is contained in:
@@ -134,21 +134,18 @@ class Router
|
||||
|
||||
$group = $route;
|
||||
|
||||
if ($route->getCallback() !== null && is_callable($route->getCallback())) {
|
||||
$this->processingRoute = true;
|
||||
$route->renderRoute($this->request);
|
||||
$this->processingRoute = false;
|
||||
|
||||
$this->processingRoute = true;
|
||||
$route->renderRoute($this->request);
|
||||
$this->processingRoute = false;
|
||||
|
||||
if ($route->matchRoute($url, $this->request) === true) {
|
||||
|
||||
/* Add exception handlers */
|
||||
if (count($route->getExceptionHandlers()) > 0) {
|
||||
/** @noinspection AdditionOperationOnArraysInspection */
|
||||
$exceptionHandlers += $route->getExceptionHandlers();
|
||||
}
|
||||
if ($route->matchRoute($url, $this->request) === true) {
|
||||
|
||||
/* Add exception handlers */
|
||||
if (count($route->getExceptionHandlers()) > 0) {
|
||||
/** @noinspection AdditionOperationOnArraysInspection */
|
||||
$exceptionHandlers += $route->getExceptionHandlers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,9 +286,9 @@ class Router
|
||||
$rewriteUrl = $this->request->getRewriteUrl();
|
||||
|
||||
if ($rewriteUrl !== null) {
|
||||
$message = sprintf('Route not found: %s (redirected from: %s)', $rewriteUrl, $this->request->getUri());
|
||||
$message = sprintf('Route not found: "%s" (rewrite from: "%s")', $rewriteUrl, $this->request->getUri());
|
||||
} else {
|
||||
$message = sprintf('Route not found: %s', $this->request->getUri());
|
||||
$message = sprintf('Route not found: "%s"', $this->request->getUri());
|
||||
}
|
||||
|
||||
$this->handleException(new NotFoundHttpException($message, 404));
|
||||
|
||||
Reference in New Issue
Block a user