mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Development
- Fixed: namespace being prepended on `RouterController` routes with absolute namespaces. - Fixed: match domain on `RouteController` and `RouteResource`. - Fixed: strict url-matching on `RouteController`. Fix should provide better url-matching. - Fixed: `RouterResource` always matching first url when having simular urls (ex: `/funny-cat` and `/funny-dog`). - Added `loadRoutes` method to `Router` class so routes now can be loaded without routing the request (useful when running in Cli etc). - Removed `getInstance` from `Router` class. Please use `SimpleRouter::router()` for singleton usage instead. - Added `getRemoteAddr` alias-method for `getIp` in `Request` class. - Added `getValue` to `IInputItem` interface. - Other minor optimizations. - Updated documentation with note on absolute/relative namespaces.
This commit is contained in:
@@ -33,6 +33,8 @@ class SimpleRouter
|
||||
*/
|
||||
protected static $response;
|
||||
|
||||
protected static $router;
|
||||
|
||||
/**
|
||||
* Start/route request
|
||||
*
|
||||
@@ -349,7 +351,11 @@ class SimpleRouter
|
||||
*/
|
||||
public static function router()
|
||||
{
|
||||
return Router::getInstance();
|
||||
if(static::$router === null) {
|
||||
static::$router = new Router();
|
||||
}
|
||||
|
||||
return static::$router;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +371,7 @@ class SimpleRouter
|
||||
$callback = $route->getCallback();
|
||||
|
||||
/* Only add default namespace on relative callbacks */
|
||||
if($callback === null || $callback[0] !== '\\') {
|
||||
if ($callback === null || $callback[0] !== '\\') {
|
||||
|
||||
$namespace = static::$defaultNamespace;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user