diff --git a/flight/Engine.php b/flight/Engine.php index ffd51e4..89b6b72 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -27,7 +27,8 @@ use flight\net\Route; * # Core methods * @method void start() Starts engine * @method void stop() Stops framework and outputs current response - * @method void halt(int $code = 200, string $message = '', bool $actuallyExit = true) Stops processing and returns a given response. + * @method void halt(int $code = 200, string $message = '', bool $actuallyExit = true) + * Stops processing and returns a given response. * * # Routing * @method Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') @@ -464,7 +465,12 @@ class Engine // Run any before middlewares if (count($route->middleware) > 0) { - $at_least_one_middleware_failed = $this->processMiddleware($route->middleware, $route->params, 'before'); + $at_least_one_middleware_failed = $this->processMiddleware( + $route->middleware, + $route->params, + 'before' + ); + if ($at_least_one_middleware_failed === true) { $failed_middleware_check = true; break; diff --git a/flight/Flight.php b/flight/Flight.php index 6e29781..4609c60 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -10,8 +10,6 @@ use flight\net\Router; use flight\template\View; use flight\net\Route; -require_once __DIR__ . '/autoload.php'; - /** * The Flight class is a static representation of the framework. * @@ -140,6 +138,8 @@ class Flight */ public static function __callStatic(string $name, array $params) { + require_once __DIR__ . '/autoload.php'; + return Dispatcher::invokeMethod([self::app(), $name], $params); } @@ -147,8 +147,6 @@ class Flight public static function app(): Engine { if (!self::$initialized) { - require_once __DIR__ . '/autoload.php'; - self::setEngine(new Engine()); self::$initialized = true; } diff --git a/index.php b/index.php index 5a21ed6..65ea154 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,9 @@ - + - @@ -39,6 +38,11 @@ + + + + + flight/ tests/ tests/views/*