/** * New Redirect Response * * @param string $filename * @param int $code * @param array $headers */ public function __construct($filename, $code = 302, array $headers = []) { parent::__construct(null, $code, $headers); $this->filename = $filename; $this->header('Content-Type', 'application/octet-stream'); $this->header('Content-Length', filesize($filename)); $this->header('Content-Disposition', 'attachment; filename=\\"' . basename($filename) . '\\"'); $this->noCache(); }
/** * New JSON Response * * @param string $content * @param int $code * @param array $headers */ public function __construct($content = null, $code = 200, array $headers = []) { $content = json_encode($content, JSON_PRETTY_PRINT); parent::__construct($content, $code, $headers); }
/** * New Redirect Response * * @param string $uri * @param int $code * @param array $headers */ public function __construct($uri, $code = 302, array $headers = []) { parent::__construct(null, $code, $headers); $this->uri = (string) $uri; }
/** * New Template Response * * @param string $template * @param array $vars * @param int $code * @param array $headers */ public function __construct($template, array $vars = [], $code = 200, array $headers = []) { parent::__construct(null, $code, $headers); $this->template = $template; $this->vars = $vars; }