public function run() { ob_start(); $request = $this->container['request']; $response = $this->container['response']; // Call before handlers if ($this->runHandlers('before', $this->container)) { $response->prepare()->send(); $this->end(); return; } // Route & execute try { $match = Router::run(Request::method(), Request::host(), Request::path()); $routeResult = $match->execute($this->container); $routeResult->render($this->container); } catch (PageNotFoundException $e) { // 404 $response->setResponseCode($e->getCode()); $this->runHandlers('missing', $this->container); } catch (HttpException $e) { // 500 $response->setResponseCode($e->getCode()); $this->runHandlers('error', $this->container); } // Call after handlers $this->runHandlers('after', $this->container); // Send our response down! $response->prepare()->send(); $this->end(); ob_end_flush(); }
public function testBack() { $url = '/notes'; $_SERVER['HTTP_REFERER'] = $url; $this->assertEquals($url, Request::referer()); $redirect = Redirect::back(); $this->assertEquals($url, $redirect->path()); }
public static function guest($url) { Session::set('url.intended', Request::path()); return new self($url); }