/** * Rendering the caught exception output. * * @return string */ public function __toString() { ob_start(); $exceptionErrorFile = __DIR__ . '/_includes/exception_error.php'; if (!file_exists($exceptionErrorFile)) { die(sprintf('Exception view [%s] not found!', $exceptionErrorFile)); } require $exceptionErrorFile; $response = $this->app->response(); $response->write(''); return $response->write(ob_get_clean())->render(); }
/** * Create respective class instances for controller usage. * Mapped and re-assign to the core instances. */ protected function factory() { $this->request = $this->app->request(); $this->response = $this->app->response(); $this->route = $this->app->route(); $this->view = $this->app->view(); return $this; }
/** * Redirect to specified path. * Default is full path with base url appended. * * @param mixed $path * @param string $baseUrl */ public function redirect($path, $baseUrl = true) { if ($baseUrl) { $path = $this->getBaseUrl() . $path; } $this->app->response()->withStatus(302); header('Location:' . $path); die; }
public function testSingletonResponseClassInstanceViaStaticMethod() { $this->assertEquals($this->app->response(), App::response()); }