示例#1
0
文件: File.php 项目: indigophp/common
 /**
  * @param string $file
  * @param string $mime
  * @param array  $headers
  */
 public function __construct(\Fuel\FileSystem\File $file, array $headers = [])
 {
     // process the passed data
     if (!$file->exists()) {
         throw new NotFound();
     }
     if (!$file->isReadable()) {
         throw new Forbidden();
     }
     $this->setContentType($file->getMimeType());
     parent::__construct($file, 200, $headers);
 }
示例#2
0
 /**
  * Method to execute for finishing up controller execution, ensures the response is a Response object
  *
  * @param   mixed  $response
  *
  * @return  Response
  *
  * @since  1.0.0
  */
 protected function after($response)
 {
     // make sure we have a valid response object
     if (!$response instanceof Response) {
         $this->response->setContent($response);
     } elseif ($response !== null) {
         $this->response = $response;
     }
     // do we need to repackage the response?
     if ($this->responseFormat !== $this->initialResponseFormat) {
         $response = $this->factory->createResponseInstance($this->responseFormat, array($this->request));
         $this->response = $response->setContent($this->response->getContent());
     }
 }
示例#3
0
 /**
  * @param string  $content
  * @param string  $contentType
  * @param integer $status
  * @param array   $headers
  */
 public function __construct($content = '', $contentType = 'application/octet-stream', $status = 200, array $headers = [])
 {
     $this->setContentType($contentType);
     parent::__construct($content, $status, $headers);
 }