Make specifying the path to the handler script optional in Route since it is not needed if using an autoloader.
This commit is contained in:
parent
331bdae7ec
commit
3ff2371edd
|
|
@ -47,7 +47,7 @@ class Route {
|
|||
* @param $handler
|
||||
* @param $handlerPath
|
||||
*/
|
||||
public function __construct($pattern, $handler, $handlerPath) {
|
||||
public function __construct($pattern, $handler, $handlerPath=null) {
|
||||
|
||||
$this->pattern = $pattern;
|
||||
$this->handler = $handler;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ class Router {
|
|||
|
||||
$klass = $route->handler;
|
||||
|
||||
if (!class_exists($klass)) {
|
||||
// Autoload, if needed.
|
||||
if (!class_exists($klass) && is_string($route->handlerPath)) {
|
||||
require_once($route->handlerPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue