/** * Private method for setting and getting whether we have a route match yet. Big difference is that this method * does not call `static::procesAvailableRoutes()` unlike its public counter part `routeMatch()`. The reason * the public method calls `static::processAvailableRoutes()` is so that say a Router was created, and * immeditatly after the a call is made to `Router::routeMatch()` to check if the last route satisifed the * request, well if the `process()` method wasn't called on it directly, it wont be processed until another * Router is created or the end of the application method `tearDown()` is called. So to make sure we respond * with the correct anwser we need to make sure any un-processed routes are processed first. * * @param boolean $m * * @return boolean */ private static function __routeMatch($m = null) { if ($m !== null) { if (static::$routeMatch === false && $m === true) { \App::make('Router', '\\Disco\\classes\\MockBox'); } else { if (static::$routeMatch === true && $m === false) { \App::makeFactory('Router', function () { return \Disco\classes\Router::factory(); }); } } //el static::$routeMatch = $m; } //if return static::$routeMatch; }
/** * Make sure a \Disco\classes\Router matched against the requested URI, and serve the necessary page. * * * @return void */ public final function tearDown() { /** * did this requested URI not find a match? If so thats a 404. */ if (!\Disco\classes\Router::routeMatch()) { \View::serve(404); } elseif (http_response_code() != 200) { \View::serve(http_response_code()); } else { \View::serve(); } //el }
public static function routeMatch($m = null) { return \Disco\classes\Router::routeMatch($m); }