@@ -39,63 +39,63 @@ |
||
39 | 39 | */ |
40 | 40 | class JSONResponse extends Response { |
41 | 41 | |
42 | - /** |
|
43 | - * response data |
|
44 | - * @var array|object |
|
45 | - */ |
|
46 | - protected $data; |
|
42 | + /** |
|
43 | + * response data |
|
44 | + * @var array|object |
|
45 | + */ |
|
46 | + protected $data; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * constructor of JSONResponse |
|
51 | - * @param array|object $data the object or array that should be transformed |
|
52 | - * @param int $statusCode the Http status code, defaults to 200 |
|
53 | - * @since 6.0.0 |
|
54 | - */ |
|
55 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
56 | - $this->data = $data; |
|
57 | - $this->setStatus($statusCode); |
|
58 | - $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
59 | - } |
|
49 | + /** |
|
50 | + * constructor of JSONResponse |
|
51 | + * @param array|object $data the object or array that should be transformed |
|
52 | + * @param int $statusCode the Http status code, defaults to 200 |
|
53 | + * @since 6.0.0 |
|
54 | + */ |
|
55 | + public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
56 | + $this->data = $data; |
|
57 | + $this->setStatus($statusCode); |
|
58 | + $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Returns the rendered json |
|
64 | - * @return string the rendered json |
|
65 | - * @since 6.0.0 |
|
66 | - * @throws \Exception If data could not get encoded |
|
67 | - */ |
|
68 | - public function render() { |
|
69 | - $response = json_encode($this->data, JSON_HEX_TAG); |
|
70 | - if($response === false) { |
|
71 | - throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
72 | - 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
|
73 | - } |
|
62 | + /** |
|
63 | + * Returns the rendered json |
|
64 | + * @return string the rendered json |
|
65 | + * @since 6.0.0 |
|
66 | + * @throws \Exception If data could not get encoded |
|
67 | + */ |
|
68 | + public function render() { |
|
69 | + $response = json_encode($this->data, JSON_HEX_TAG); |
|
70 | + if($response === false) { |
|
71 | + throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
72 | + 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
|
73 | + } |
|
74 | 74 | |
75 | - return $response; |
|
76 | - } |
|
75 | + return $response; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets values in the data json array |
|
80 | - * @param array|object $data an array or object which will be transformed |
|
81 | - * to JSON |
|
82 | - * @return JSONResponse Reference to this object |
|
83 | - * @since 6.0.0 - return value was added in 7.0.0 |
|
84 | - */ |
|
85 | - public function setData($data){ |
|
86 | - $this->data = $data; |
|
78 | + /** |
|
79 | + * Sets values in the data json array |
|
80 | + * @param array|object $data an array or object which will be transformed |
|
81 | + * to JSON |
|
82 | + * @return JSONResponse Reference to this object |
|
83 | + * @since 6.0.0 - return value was added in 7.0.0 |
|
84 | + */ |
|
85 | + public function setData($data){ |
|
86 | + $this->data = $data; |
|
87 | 87 | |
88 | - return $this; |
|
89 | - } |
|
88 | + return $this; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Used to get the set parameters |
|
94 | - * @return array the data |
|
95 | - * @since 6.0.0 |
|
96 | - */ |
|
97 | - public function getData(){ |
|
98 | - return $this->data; |
|
99 | - } |
|
92 | + /** |
|
93 | + * Used to get the set parameters |
|
94 | + * @return array the data |
|
95 | + * @since 6.0.0 |
|
96 | + */ |
|
97 | + public function getData(){ |
|
98 | + return $this->data; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param int $statusCode the Http status code, defaults to 200 |
53 | 53 | * @since 6.0.0 |
54 | 54 | */ |
55 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
55 | + public function __construct($data = array(), $statusCode = Http::STATUS_OK) { |
|
56 | 56 | $this->data = $data; |
57 | 57 | $this->setStatus($statusCode); |
58 | 58 | $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function render() { |
69 | 69 | $response = json_encode($this->data, JSON_HEX_TAG); |
70 | - if($response === false) { |
|
71 | - throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
70 | + if ($response === false) { |
|
71 | + throw new \Exception(sprintf('Could not json_encode due to invalid '. |
|
72 | 72 | 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
73 | 73 | } |
74 | 74 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return JSONResponse Reference to this object |
83 | 83 | * @since 6.0.0 - return value was added in 7.0.0 |
84 | 84 | */ |
85 | - public function setData($data){ |
|
85 | + public function setData($data) { |
|
86 | 86 | $this->data = $data; |
87 | 87 | |
88 | 88 | return $this; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return array the data |
95 | 95 | * @since 6.0.0 |
96 | 96 | */ |
97 | - public function getData(){ |
|
97 | + public function getData() { |
|
98 | 98 | return $this->data; |
99 | 99 | } |
100 | 100 |
@@ -37,48 +37,48 @@ |
||
37 | 37 | */ |
38 | 38 | class DataResponse extends Response { |
39 | 39 | |
40 | - /** |
|
41 | - * response data |
|
42 | - * @var array|object |
|
43 | - */ |
|
44 | - protected $data; |
|
40 | + /** |
|
41 | + * response data |
|
42 | + * @var array|object |
|
43 | + */ |
|
44 | + protected $data; |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @param array|object $data the object or array that should be transformed |
|
49 | - * @param int $statusCode the Http status code, defaults to 200 |
|
50 | - * @param array $headers additional key value based headers |
|
51 | - * @since 8.0.0 |
|
52 | - */ |
|
53 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | - array $headers=array()) { |
|
55 | - $this->data = $data; |
|
56 | - $this->setStatus($statusCode); |
|
57 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
58 | - } |
|
47 | + /** |
|
48 | + * @param array|object $data the object or array that should be transformed |
|
49 | + * @param int $statusCode the Http status code, defaults to 200 |
|
50 | + * @param array $headers additional key value based headers |
|
51 | + * @since 8.0.0 |
|
52 | + */ |
|
53 | + public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | + array $headers=array()) { |
|
55 | + $this->data = $data; |
|
56 | + $this->setStatus($statusCode); |
|
57 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Sets values in the data json array |
|
63 | - * @param array|object $data an array or object which will be transformed |
|
64 | - * @return DataResponse Reference to this object |
|
65 | - * @since 8.0.0 |
|
66 | - */ |
|
67 | - public function setData($data){ |
|
68 | - $this->data = $data; |
|
61 | + /** |
|
62 | + * Sets values in the data json array |
|
63 | + * @param array|object $data an array or object which will be transformed |
|
64 | + * @return DataResponse Reference to this object |
|
65 | + * @since 8.0.0 |
|
66 | + */ |
|
67 | + public function setData($data){ |
|
68 | + $this->data = $data; |
|
69 | 69 | |
70 | - return $this; |
|
71 | - } |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * Used to get the set parameters |
|
76 | - * @return array the data |
|
77 | - * @since 8.0.0 |
|
78 | - */ |
|
79 | - public function getData(){ |
|
80 | - return $this->data; |
|
81 | - } |
|
74 | + /** |
|
75 | + * Used to get the set parameters |
|
76 | + * @return array the data |
|
77 | + * @since 8.0.0 |
|
78 | + */ |
|
79 | + public function getData(){ |
|
80 | + return $this->data; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @param array $headers additional key value based headers |
51 | 51 | * @since 8.0.0 |
52 | 52 | */ |
53 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | - array $headers=array()) { |
|
53 | + public function __construct($data = array(), $statusCode = Http::STATUS_OK, |
|
54 | + array $headers = array()) { |
|
55 | 55 | $this->data = $data; |
56 | 56 | $this->setStatus($statusCode); |
57 | 57 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return DataResponse Reference to this object |
65 | 65 | * @since 8.0.0 |
66 | 66 | */ |
67 | - public function setData($data){ |
|
67 | + public function setData($data) { |
|
68 | 68 | $this->data = $data; |
69 | 69 | |
70 | 70 | return $this; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return array the data |
77 | 77 | * @since 8.0.0 |
78 | 78 | */ |
79 | - public function getData(){ |
|
79 | + public function getData() { |
|
80 | 80 | return $this->data; |
81 | 81 | } |
82 | 82 |
@@ -29,36 +29,36 @@ |
||
29 | 29 | * @since 8.0.0 |
30 | 30 | */ |
31 | 31 | class DataDownloadResponse extends DownloadResponse { |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - private $data; |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + private $data; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Creates a response that prompts the user to download the text |
|
39 | - * @param string $data text to be downloaded |
|
40 | - * @param string $filename the name that the downloaded file should have |
|
41 | - * @param string $contentType the mimetype that the downloaded file should have |
|
42 | - * @since 8.0.0 |
|
43 | - */ |
|
44 | - public function __construct($data, $filename, $contentType) { |
|
45 | - $this->data = $data; |
|
46 | - parent::__construct($filename, $contentType); |
|
47 | - } |
|
37 | + /** |
|
38 | + * Creates a response that prompts the user to download the text |
|
39 | + * @param string $data text to be downloaded |
|
40 | + * @param string $filename the name that the downloaded file should have |
|
41 | + * @param string $contentType the mimetype that the downloaded file should have |
|
42 | + * @since 8.0.0 |
|
43 | + */ |
|
44 | + public function __construct($data, $filename, $contentType) { |
|
45 | + $this->data = $data; |
|
46 | + parent::__construct($filename, $contentType); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $data |
|
51 | - * @since 8.0.0 |
|
52 | - */ |
|
53 | - public function setData($data) { |
|
54 | - $this->data = $data; |
|
55 | - } |
|
49 | + /** |
|
50 | + * @param string $data |
|
51 | + * @since 8.0.0 |
|
52 | + */ |
|
53 | + public function setData($data) { |
|
54 | + $this->data = $data; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - * @since 8.0.0 |
|
60 | - */ |
|
61 | - public function render() { |
|
62 | - return $this->data; |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + * @since 8.0.0 |
|
60 | + */ |
|
61 | + public function render() { |
|
62 | + return $this->data; |
|
63 | + } |
|
64 | 64 | } |
@@ -32,38 +32,38 @@ |
||
32 | 32 | */ |
33 | 33 | class FileDisplayResponse extends Response implements ICallbackResponse { |
34 | 34 | |
35 | - /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | - private $file; |
|
35 | + /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | + private $file; |
|
37 | 37 | |
38 | - /** |
|
39 | - * FileDisplayResponse constructor. |
|
40 | - * |
|
41 | - * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | - * @param int $statusCode |
|
43 | - * @param array $headers |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
48 | - $this->file = $file; |
|
49 | - $this->setStatus($statusCode); |
|
50 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
51 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
38 | + /** |
|
39 | + * FileDisplayResponse constructor. |
|
40 | + * |
|
41 | + * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | + * @param int $statusCode |
|
43 | + * @param array $headers |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | + $headers=[]) { |
|
48 | + $this->file = $file; |
|
49 | + $this->setStatus($statusCode); |
|
50 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
51 | + $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
52 | 52 | |
53 | - $this->setETag($file->getEtag()); |
|
54 | - $lastModified = new \DateTime(); |
|
55 | - $lastModified->setTimestamp($file->getMTime()); |
|
56 | - $this->setLastModified($lastModified); |
|
57 | - } |
|
53 | + $this->setETag($file->getEtag()); |
|
54 | + $lastModified = new \DateTime(); |
|
55 | + $lastModified->setTimestamp($file->getMTime()); |
|
56 | + $this->setLastModified($lastModified); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param IOutput $output |
|
61 | - * @since 11.0.0 |
|
62 | - */ |
|
63 | - public function callback(IOutput $output) { |
|
64 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
65 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
66 | - $output->setOutput($this->file->getContent()); |
|
67 | - } |
|
68 | - } |
|
59 | + /** |
|
60 | + * @param IOutput $output |
|
61 | + * @since 11.0.0 |
|
62 | + */ |
|
63 | + public function callback(IOutput $output) { |
|
64 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
65 | + $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
66 | + $output->setOutput($this->file->getContent()); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @param array $headers |
44 | 44 | * @since 11.0.0 |
45 | 45 | */ |
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
46 | + public function __construct($file, $statusCode = Http::STATUS_OK, |
|
47 | + $headers = []) { |
|
48 | 48 | $this->file = $file; |
49 | 49 | $this->setStatus($statusCode); |
50 | 50 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
51 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
51 | + $this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"'); |
|
52 | 52 | |
53 | 53 | $this->setETag($file->getEtag()); |
54 | 54 | $lastModified = new \DateTime(); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function callback(IOutput $output) { |
64 | 64 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
65 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
65 | + $output->setHeader('Content-Length: '.$this->file->getSize()); |
|
66 | 66 | $output->setOutput($this->file->getContent()); |
67 | 67 | } |
68 | 68 | } |
@@ -32,19 +32,19 @@ |
||
32 | 32 | */ |
33 | 33 | class NotFoundResponse extends Response { |
34 | 34 | |
35 | - /** |
|
36 | - * @since 8.1.0 |
|
37 | - */ |
|
38 | - public function __construct() { |
|
39 | - $this->setStatus(404); |
|
40 | - } |
|
35 | + /** |
|
36 | + * @since 8.1.0 |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | + $this->setStatus(404); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - * @since 8.1.0 |
|
45 | - */ |
|
46 | - public function render() { |
|
47 | - $template = new Template('core', '404', 'guest'); |
|
48 | - return $template->fetchPage(); |
|
49 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + * @since 8.1.0 |
|
45 | + */ |
|
46 | + public function render() { |
|
47 | + $template = new Template('core', '404', 'guest'); |
|
48 | + return $template->fetchPage(); |
|
49 | + } |
|
50 | 50 | } |
@@ -32,48 +32,48 @@ |
||
32 | 32 | */ |
33 | 33 | interface IOutput { |
34 | 34 | |
35 | - /** |
|
36 | - * @param string $out |
|
37 | - * @since 8.1.0 |
|
38 | - */ |
|
39 | - public function setOutput($out); |
|
35 | + /** |
|
36 | + * @param string $out |
|
37 | + * @since 8.1.0 |
|
38 | + */ |
|
39 | + public function setOutput($out); |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string|resource $path or file handle |
|
43 | - * |
|
44 | - * @return bool false if an error occurred |
|
45 | - * @since 8.1.0 |
|
46 | - */ |
|
47 | - public function setReadfile($path); |
|
41 | + /** |
|
42 | + * @param string|resource $path or file handle |
|
43 | + * |
|
44 | + * @return bool false if an error occurred |
|
45 | + * @since 8.1.0 |
|
46 | + */ |
|
47 | + public function setReadfile($path); |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $header |
|
51 | - * @since 8.1.0 |
|
52 | - */ |
|
53 | - public function setHeader($header); |
|
49 | + /** |
|
50 | + * @param string $header |
|
51 | + * @since 8.1.0 |
|
52 | + */ |
|
53 | + public function setHeader($header); |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return int returns the current http response code |
|
57 | - * @since 8.1.0 |
|
58 | - */ |
|
59 | - public function getHttpResponseCode(); |
|
55 | + /** |
|
56 | + * @return int returns the current http response code |
|
57 | + * @since 8.1.0 |
|
58 | + */ |
|
59 | + public function getHttpResponseCode(); |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param int $code sets the http status code |
|
63 | - * @since 8.1.0 |
|
64 | - */ |
|
65 | - public function setHttpResponseCode($code); |
|
61 | + /** |
|
62 | + * @param int $code sets the http status code |
|
63 | + * @since 8.1.0 |
|
64 | + */ |
|
65 | + public function setHttpResponseCode($code); |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param string $name |
|
69 | - * @param string $value |
|
70 | - * @param int $expire |
|
71 | - * @param string $path |
|
72 | - * @param string $domain |
|
73 | - * @param bool $secure |
|
74 | - * @param bool $httpOnly |
|
75 | - * @since 8.1.0 |
|
76 | - */ |
|
77 | - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); |
|
67 | + /** |
|
68 | + * @param string $name |
|
69 | + * @param string $value |
|
70 | + * @param int $expire |
|
71 | + * @param string $path |
|
72 | + * @param string $domain |
|
73 | + * @param bool $secure |
|
74 | + * @param bool $httpOnly |
|
75 | + * @since 8.1.0 |
|
76 | + */ |
|
77 | + public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); |
|
78 | 78 | |
79 | 79 | } |
@@ -33,33 +33,33 @@ |
||
33 | 33 | * @since 8.1.0 |
34 | 34 | */ |
35 | 35 | class StreamResponse extends Response implements ICallbackResponse { |
36 | - /** @var string */ |
|
37 | - private $filePath; |
|
36 | + /** @var string */ |
|
37 | + private $filePath; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
41 | - * @since 8.1.0 |
|
42 | - */ |
|
43 | - public function __construct ($filePath) { |
|
44 | - $this->filePath = $filePath; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
41 | + * @since 8.1.0 |
|
42 | + */ |
|
43 | + public function __construct ($filePath) { |
|
44 | + $this->filePath = $filePath; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Streams the file using readfile |
|
50 | - * |
|
51 | - * @param IOutput $output a small wrapper that handles output |
|
52 | - * @since 8.1.0 |
|
53 | - */ |
|
54 | - public function callback (IOutput $output) { |
|
55 | - // handle caching |
|
56 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | - if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
58 | - $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | - } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | - $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
48 | + /** |
|
49 | + * Streams the file using readfile |
|
50 | + * |
|
51 | + * @param IOutput $output a small wrapper that handles output |
|
52 | + * @since 8.1.0 |
|
53 | + */ |
|
54 | + public function callback (IOutput $output) { |
|
55 | + // handle caching |
|
56 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | + if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
58 | + $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | + } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | + $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string|resource $filePath the path to the file or a file handle which should be streamed |
41 | 41 | * @since 8.1.0 |
42 | 42 | */ |
43 | - public function __construct ($filePath) { |
|
43 | + public function __construct($filePath) { |
|
44 | 44 | $this->filePath = $filePath; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param IOutput $output a small wrapper that handles output |
52 | 52 | * @since 8.1.0 |
53 | 53 | */ |
54 | - public function callback (IOutput $output) { |
|
54 | + public function callback(IOutput $output) { |
|
55 | 55 | // handle caching |
56 | 56 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
57 | 57 | if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
@@ -32,22 +32,22 @@ |
||
32 | 32 | */ |
33 | 33 | class DownloadResponse extends \OCP\AppFramework\Http\Response { |
34 | 34 | |
35 | - private $filename; |
|
36 | - private $contentType; |
|
37 | - |
|
38 | - /** |
|
39 | - * Creates a response that prompts the user to download the file |
|
40 | - * @param string $filename the name that the downloaded file should have |
|
41 | - * @param string $contentType the mimetype that the downloaded file should have |
|
42 | - * @since 7.0.0 |
|
43 | - */ |
|
44 | - public function __construct($filename, $contentType) { |
|
45 | - $this->filename = $filename; |
|
46 | - $this->contentType = $contentType; |
|
47 | - |
|
48 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | - $this->addHeader('Content-Type', $contentType); |
|
50 | - } |
|
35 | + private $filename; |
|
36 | + private $contentType; |
|
37 | + |
|
38 | + /** |
|
39 | + * Creates a response that prompts the user to download the file |
|
40 | + * @param string $filename the name that the downloaded file should have |
|
41 | + * @param string $contentType the mimetype that the downloaded file should have |
|
42 | + * @since 7.0.0 |
|
43 | + */ |
|
44 | + public function __construct($filename, $contentType) { |
|
45 | + $this->filename = $filename; |
|
46 | + $this->contentType = $contentType; |
|
47 | + |
|
48 | + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | + $this->addHeader('Content-Type', $contentType); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $this->filename = $filename; |
46 | 46 | $this->contentType = $contentType; |
47 | 47 | |
48 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
48 | + $this->addHeader('Content-Disposition', 'attachment; filename="'.$filename.'"'); |
|
49 | 49 | $this->addHeader('Content-Type', $contentType); |
50 | 50 | } |
51 | 51 |
@@ -44,69 +44,69 @@ |
||
44 | 44 | abstract class Middleware { |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * This is being run in normal order before the controller is being |
|
49 | - * called which allows several modifications and checks |
|
50 | - * |
|
51 | - * @param Controller $controller the controller that is being called |
|
52 | - * @param string $methodName the name of the method that will be called on |
|
53 | - * the controller |
|
54 | - * @since 6.0.0 |
|
55 | - */ |
|
56 | - public function beforeController($controller, $methodName){ |
|
47 | + /** |
|
48 | + * This is being run in normal order before the controller is being |
|
49 | + * called which allows several modifications and checks |
|
50 | + * |
|
51 | + * @param Controller $controller the controller that is being called |
|
52 | + * @param string $methodName the name of the method that will be called on |
|
53 | + * the controller |
|
54 | + * @since 6.0.0 |
|
55 | + */ |
|
56 | + public function beforeController($controller, $methodName){ |
|
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * This is being run when either the beforeController method or the |
|
63 | - * controller method itself is throwing an exception. The middleware is |
|
64 | - * asked in reverse order to handle the exception and to return a response. |
|
65 | - * If the response is null, it is assumed that the exception could not be |
|
66 | - * handled and the error will be thrown again |
|
67 | - * |
|
68 | - * @param Controller $controller the controller that is being called |
|
69 | - * @param string $methodName the name of the method that will be called on |
|
70 | - * the controller |
|
71 | - * @param \Exception $exception the thrown exception |
|
72 | - * @throws \Exception the passed in exception if it can't handle it |
|
73 | - * @return Response a Response object in case that the exception was handled |
|
74 | - * @since 6.0.0 |
|
75 | - */ |
|
76 | - public function afterException($controller, $methodName, \Exception $exception){ |
|
77 | - throw $exception; |
|
78 | - } |
|
61 | + /** |
|
62 | + * This is being run when either the beforeController method or the |
|
63 | + * controller method itself is throwing an exception. The middleware is |
|
64 | + * asked in reverse order to handle the exception and to return a response. |
|
65 | + * If the response is null, it is assumed that the exception could not be |
|
66 | + * handled and the error will be thrown again |
|
67 | + * |
|
68 | + * @param Controller $controller the controller that is being called |
|
69 | + * @param string $methodName the name of the method that will be called on |
|
70 | + * the controller |
|
71 | + * @param \Exception $exception the thrown exception |
|
72 | + * @throws \Exception the passed in exception if it can't handle it |
|
73 | + * @return Response a Response object in case that the exception was handled |
|
74 | + * @since 6.0.0 |
|
75 | + */ |
|
76 | + public function afterException($controller, $methodName, \Exception $exception){ |
|
77 | + throw $exception; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * This is being run after a successful controllermethod call and allows |
|
83 | - * the manipulation of a Response object. The middleware is run in reverse order |
|
84 | - * |
|
85 | - * @param Controller $controller the controller that is being called |
|
86 | - * @param string $methodName the name of the method that will be called on |
|
87 | - * the controller |
|
88 | - * @param Response $response the generated response from the controller |
|
89 | - * @return Response a Response object |
|
90 | - * @since 6.0.0 |
|
91 | - */ |
|
92 | - public function afterController($controller, $methodName, Response $response){ |
|
93 | - return $response; |
|
94 | - } |
|
81 | + /** |
|
82 | + * This is being run after a successful controllermethod call and allows |
|
83 | + * the manipulation of a Response object. The middleware is run in reverse order |
|
84 | + * |
|
85 | + * @param Controller $controller the controller that is being called |
|
86 | + * @param string $methodName the name of the method that will be called on |
|
87 | + * the controller |
|
88 | + * @param Response $response the generated response from the controller |
|
89 | + * @return Response a Response object |
|
90 | + * @since 6.0.0 |
|
91 | + */ |
|
92 | + public function afterController($controller, $methodName, Response $response){ |
|
93 | + return $response; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * This is being run after the response object has been rendered and |
|
99 | - * allows the manipulation of the output. The middleware is run in reverse order |
|
100 | - * |
|
101 | - * @param Controller $controller the controller that is being called |
|
102 | - * @param string $methodName the name of the method that will be called on |
|
103 | - * the controller |
|
104 | - * @param string $output the generated output from a response |
|
105 | - * @return string the output that should be printed |
|
106 | - * @since 6.0.0 |
|
107 | - */ |
|
108 | - public function beforeOutput($controller, $methodName, $output){ |
|
109 | - return $output; |
|
110 | - } |
|
97 | + /** |
|
98 | + * This is being run after the response object has been rendered and |
|
99 | + * allows the manipulation of the output. The middleware is run in reverse order |
|
100 | + * |
|
101 | + * @param Controller $controller the controller that is being called |
|
102 | + * @param string $methodName the name of the method that will be called on |
|
103 | + * the controller |
|
104 | + * @param string $output the generated output from a response |
|
105 | + * @return string the output that should be printed |
|
106 | + * @since 6.0.0 |
|
107 | + */ |
|
108 | + public function beforeOutput($controller, $methodName, $output){ |
|
109 | + return $output; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * the controller |
54 | 54 | * @since 6.0.0 |
55 | 55 | */ |
56 | - public function beforeController($controller, $methodName){ |
|
56 | + public function beforeController($controller, $methodName) { |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return Response a Response object in case that the exception was handled |
74 | 74 | * @since 6.0.0 |
75 | 75 | */ |
76 | - public function afterException($controller, $methodName, \Exception $exception){ |
|
76 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
77 | 77 | throw $exception; |
78 | 78 | } |
79 | 79 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return Response a Response object |
90 | 90 | * @since 6.0.0 |
91 | 91 | */ |
92 | - public function afterController($controller, $methodName, Response $response){ |
|
92 | + public function afterController($controller, $methodName, Response $response) { |
|
93 | 93 | return $response; |
94 | 94 | } |
95 | 95 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string the output that should be printed |
106 | 106 | * @since 6.0.0 |
107 | 107 | */ |
108 | - public function beforeOutput($controller, $methodName, $output){ |
|
108 | + public function beforeOutput($controller, $methodName, $output) { |
|
109 | 109 | return $output; |
110 | 110 | } |
111 | 111 |