@@ -36,91 +36,91 @@ |
||
36 | 36 | */ |
37 | 37 | interface IRouter { |
38 | 38 | |
39 | - /** |
|
40 | - * Get the files to load the routes from |
|
41 | - * |
|
42 | - * @return string[] |
|
43 | - * @since 7.0.0 |
|
44 | - * @deprecated 9.0.0 |
|
45 | - */ |
|
46 | - public function getRoutingFiles(); |
|
39 | + /** |
|
40 | + * Get the files to load the routes from |
|
41 | + * |
|
42 | + * @return string[] |
|
43 | + * @since 7.0.0 |
|
44 | + * @deprecated 9.0.0 |
|
45 | + */ |
|
46 | + public function getRoutingFiles(); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string |
|
50 | - * @since 7.0.0 |
|
51 | - * @deprecated 9.0.0 |
|
52 | - */ |
|
53 | - public function getCacheKey(); |
|
48 | + /** |
|
49 | + * @return string |
|
50 | + * @since 7.0.0 |
|
51 | + * @deprecated 9.0.0 |
|
52 | + */ |
|
53 | + public function getCacheKey(); |
|
54 | 54 | |
55 | - /** |
|
56 | - * Loads the routes |
|
57 | - * |
|
58 | - * @param null|string $app |
|
59 | - * @since 7.0.0 |
|
60 | - * @deprecated 9.0.0 |
|
61 | - */ |
|
62 | - public function loadRoutes($app = null); |
|
55 | + /** |
|
56 | + * Loads the routes |
|
57 | + * |
|
58 | + * @param null|string $app |
|
59 | + * @since 7.0.0 |
|
60 | + * @deprecated 9.0.0 |
|
61 | + */ |
|
62 | + public function loadRoutes($app = null); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Sets the collection to use for adding routes |
|
66 | - * |
|
67 | - * @param string $name Name of the collection to use. |
|
68 | - * @return void |
|
69 | - * @since 7.0.0 |
|
70 | - * @deprecated 9.0.0 |
|
71 | - */ |
|
72 | - public function useCollection($name); |
|
64 | + /** |
|
65 | + * Sets the collection to use for adding routes |
|
66 | + * |
|
67 | + * @param string $name Name of the collection to use. |
|
68 | + * @return void |
|
69 | + * @since 7.0.0 |
|
70 | + * @deprecated 9.0.0 |
|
71 | + */ |
|
72 | + public function useCollection($name); |
|
73 | 73 | |
74 | - /** |
|
75 | - * returns the current collection name in use for adding routes |
|
76 | - * |
|
77 | - * @return string the collection name |
|
78 | - * @since 8.0.0 |
|
79 | - * @deprecated 9.0.0 |
|
80 | - */ |
|
81 | - public function getCurrentCollection(); |
|
74 | + /** |
|
75 | + * returns the current collection name in use for adding routes |
|
76 | + * |
|
77 | + * @return string the collection name |
|
78 | + * @since 8.0.0 |
|
79 | + * @deprecated 9.0.0 |
|
80 | + */ |
|
81 | + public function getCurrentCollection(); |
|
82 | 82 | |
83 | - /** |
|
84 | - * Create a \OCP\Route\IRoute. |
|
85 | - * |
|
86 | - * @param string $name Name of the route to create. |
|
87 | - * @param string $pattern The pattern to match |
|
88 | - * @param array $defaults An array of default parameter values |
|
89 | - * @param array $requirements An array of requirements for parameters (regexes) |
|
90 | - * @return \OCP\Route\IRoute |
|
91 | - * @since 7.0.0 |
|
92 | - * @deprecated 9.0.0 |
|
93 | - */ |
|
94 | - public function create($name, $pattern, array $defaults = [], array $requirements = []); |
|
83 | + /** |
|
84 | + * Create a \OCP\Route\IRoute. |
|
85 | + * |
|
86 | + * @param string $name Name of the route to create. |
|
87 | + * @param string $pattern The pattern to match |
|
88 | + * @param array $defaults An array of default parameter values |
|
89 | + * @param array $requirements An array of requirements for parameters (regexes) |
|
90 | + * @return \OCP\Route\IRoute |
|
91 | + * @since 7.0.0 |
|
92 | + * @deprecated 9.0.0 |
|
93 | + */ |
|
94 | + public function create($name, $pattern, array $defaults = [], array $requirements = []); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Find the route matching $url. |
|
98 | - * |
|
99 | - * @param string $url The url to find |
|
100 | - * @throws \Exception |
|
101 | - * @return void |
|
102 | - * @since 7.0.0 |
|
103 | - * @deprecated 9.0.0 |
|
104 | - */ |
|
105 | - public function match($url); |
|
96 | + /** |
|
97 | + * Find the route matching $url. |
|
98 | + * |
|
99 | + * @param string $url The url to find |
|
100 | + * @throws \Exception |
|
101 | + * @return void |
|
102 | + * @since 7.0.0 |
|
103 | + * @deprecated 9.0.0 |
|
104 | + */ |
|
105 | + public function match($url); |
|
106 | 106 | |
107 | - /** |
|
108 | - * Get the url generator |
|
109 | - * |
|
110 | - * @since 7.0.0 |
|
111 | - * @deprecated 9.0.0 |
|
112 | - */ |
|
113 | - public function getGenerator(); |
|
107 | + /** |
|
108 | + * Get the url generator |
|
109 | + * |
|
110 | + * @since 7.0.0 |
|
111 | + * @deprecated 9.0.0 |
|
112 | + */ |
|
113 | + public function getGenerator(); |
|
114 | 114 | |
115 | - /** |
|
116 | - * Generate url based on $name and $parameters |
|
117 | - * |
|
118 | - * @param string $name Name of the route to use. |
|
119 | - * @param array $parameters Parameters for the route |
|
120 | - * @param bool $absolute |
|
121 | - * @return string |
|
122 | - * @since 7.0.0 |
|
123 | - * @deprecated 9.0.0 |
|
124 | - */ |
|
125 | - public function generate($name, $parameters = [], $absolute = false); |
|
115 | + /** |
|
116 | + * Generate url based on $name and $parameters |
|
117 | + * |
|
118 | + * @param string $name Name of the route to use. |
|
119 | + * @param array $parameters Parameters for the route |
|
120 | + * @param bool $absolute |
|
121 | + * @return string |
|
122 | + * @since 7.0.0 |
|
123 | + * @deprecated 9.0.0 |
|
124 | + */ |
|
125 | + public function generate($name, $parameters = [], $absolute = false); |
|
126 | 126 | } |
@@ -28,39 +28,39 @@ |
||
28 | 28 | * @since 8.2.0 |
29 | 29 | */ |
30 | 30 | interface ICompositeExpression { |
31 | - /** |
|
32 | - * Adds multiple parts to composite expression. |
|
33 | - * |
|
34 | - * @param array $parts |
|
35 | - * |
|
36 | - * @return ICompositeExpression |
|
37 | - * @since 8.2.0 |
|
38 | - */ |
|
39 | - public function addMultiple(array $parts = []); |
|
31 | + /** |
|
32 | + * Adds multiple parts to composite expression. |
|
33 | + * |
|
34 | + * @param array $parts |
|
35 | + * |
|
36 | + * @return ICompositeExpression |
|
37 | + * @since 8.2.0 |
|
38 | + */ |
|
39 | + public function addMultiple(array $parts = []); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Adds an expression to composite expression. |
|
43 | - * |
|
44 | - * @param mixed $part |
|
45 | - * |
|
46 | - * @return ICompositeExpression |
|
47 | - * @since 8.2.0 |
|
48 | - */ |
|
49 | - public function add($part); |
|
41 | + /** |
|
42 | + * Adds an expression to composite expression. |
|
43 | + * |
|
44 | + * @param mixed $part |
|
45 | + * |
|
46 | + * @return ICompositeExpression |
|
47 | + * @since 8.2.0 |
|
48 | + */ |
|
49 | + public function add($part); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Retrieves the amount of expressions on composite expression. |
|
53 | - * |
|
54 | - * @return integer |
|
55 | - * @since 8.2.0 |
|
56 | - */ |
|
57 | - public function count(); |
|
51 | + /** |
|
52 | + * Retrieves the amount of expressions on composite expression. |
|
53 | + * |
|
54 | + * @return integer |
|
55 | + * @since 8.2.0 |
|
56 | + */ |
|
57 | + public function count(); |
|
58 | 58 | |
59 | - /** |
|
60 | - * Returns the type of this composite expression (AND/OR). |
|
61 | - * |
|
62 | - * @return string |
|
63 | - * @since 8.2.0 |
|
64 | - */ |
|
65 | - public function getType(); |
|
59 | + /** |
|
60 | + * Returns the type of this composite expression (AND/OR). |
|
61 | + * |
|
62 | + * @return string |
|
63 | + * @since 8.2.0 |
|
64 | + */ |
|
65 | + public function getType(); |
|
66 | 66 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | // default responders |
80 | 80 | $this->responders = [ |
81 | - 'json' => function ($data) { |
|
81 | + 'json' => function($data) { |
|
82 | 82 | if ($data instanceof DataResponse) { |
83 | 83 | $response = new JSONResponse( |
84 | 84 | $data->getData(), |
@@ -153,6 +153,6 @@ discard block |
||
153 | 153 | return $responder($response); |
154 | 154 | } |
155 | 155 | throw new \DomainException('No responder registered for format '. |
156 | - $format . '!'); |
|
156 | + $format.'!'); |
|
157 | 157 | } |
158 | 158 | } |
@@ -45,122 +45,122 @@ |
||
45 | 45 | */ |
46 | 46 | abstract class Controller { |
47 | 47 | |
48 | - /** |
|
49 | - * app name |
|
50 | - * @var string |
|
51 | - * @since 7.0.0 |
|
52 | - */ |
|
53 | - protected $appName; |
|
54 | - |
|
55 | - /** |
|
56 | - * current request |
|
57 | - * @var \OCP\IRequest |
|
58 | - * @since 6.0.0 |
|
59 | - */ |
|
60 | - protected $request; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var array |
|
64 | - * @since 7.0.0 |
|
65 | - */ |
|
66 | - private $responders; |
|
67 | - |
|
68 | - /** |
|
69 | - * constructor of the controller |
|
70 | - * @param string $appName the name of the app |
|
71 | - * @param IRequest $request an instance of the request |
|
72 | - * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0 |
|
73 | - */ |
|
74 | - public function __construct($appName, |
|
75 | - IRequest $request) { |
|
76 | - $this->appName = $appName; |
|
77 | - $this->request = $request; |
|
78 | - |
|
79 | - // default responders |
|
80 | - $this->responders = [ |
|
81 | - 'json' => function ($data) { |
|
82 | - if ($data instanceof DataResponse) { |
|
83 | - $response = new JSONResponse( |
|
84 | - $data->getData(), |
|
85 | - $data->getStatus() |
|
86 | - ); |
|
87 | - $dataHeaders = $data->getHeaders(); |
|
88 | - $headers = $response->getHeaders(); |
|
89 | - // do not overwrite Content-Type if it already exists |
|
90 | - if (isset($dataHeaders['Content-Type'])) { |
|
91 | - unset($headers['Content-Type']); |
|
92 | - } |
|
93 | - $response->setHeaders(array_merge($dataHeaders, $headers)); |
|
94 | - |
|
95 | - if ($data->getETag() !== null) { |
|
96 | - $response->setETag($data->getETag()); |
|
97 | - } |
|
98 | - if ($data->getLastModified() !== null) { |
|
99 | - $response->setLastModified($data->getLastModified()); |
|
100 | - } |
|
101 | - |
|
102 | - return $response; |
|
103 | - } |
|
104 | - return new JSONResponse($data); |
|
105 | - } |
|
106 | - ]; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Parses an HTTP accept header and returns the supported responder type |
|
112 | - * @param string $acceptHeader |
|
113 | - * @param string $default |
|
114 | - * @return string the responder type |
|
115 | - * @since 7.0.0 |
|
116 | - * @since 9.1.0 Added default parameter |
|
117 | - */ |
|
118 | - public function getResponderByHTTPHeader($acceptHeader, $default = 'json') { |
|
119 | - $headers = explode(',', $acceptHeader); |
|
120 | - |
|
121 | - // return the first matching responder |
|
122 | - foreach ($headers as $header) { |
|
123 | - $header = strtolower(trim($header)); |
|
124 | - |
|
125 | - $responder = str_replace('application/', '', $header); |
|
126 | - |
|
127 | - if (array_key_exists($responder, $this->responders)) { |
|
128 | - return $responder; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - // no matching header return default |
|
133 | - return $default; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Registers a formatter for a type |
|
139 | - * @param string $format |
|
140 | - * @param \Closure $responder |
|
141 | - * @since 7.0.0 |
|
142 | - */ |
|
143 | - protected function registerResponder($format, \Closure $responder) { |
|
144 | - $this->responders[$format] = $responder; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Serializes and formats a response |
|
150 | - * @param mixed $response the value that was returned from a controller and |
|
151 | - * is not a Response instance |
|
152 | - * @param string $format the format for which a formatter has been registered |
|
153 | - * @throws \DomainException if format does not match a registered formatter |
|
154 | - * @return Response |
|
155 | - * @since 7.0.0 |
|
156 | - */ |
|
157 | - public function buildResponse($response, $format = 'json') { |
|
158 | - if (array_key_exists($format, $this->responders)) { |
|
159 | - $responder = $this->responders[$format]; |
|
160 | - |
|
161 | - return $responder($response); |
|
162 | - } |
|
163 | - throw new \DomainException('No responder registered for format '. |
|
164 | - $format . '!'); |
|
165 | - } |
|
48 | + /** |
|
49 | + * app name |
|
50 | + * @var string |
|
51 | + * @since 7.0.0 |
|
52 | + */ |
|
53 | + protected $appName; |
|
54 | + |
|
55 | + /** |
|
56 | + * current request |
|
57 | + * @var \OCP\IRequest |
|
58 | + * @since 6.0.0 |
|
59 | + */ |
|
60 | + protected $request; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var array |
|
64 | + * @since 7.0.0 |
|
65 | + */ |
|
66 | + private $responders; |
|
67 | + |
|
68 | + /** |
|
69 | + * constructor of the controller |
|
70 | + * @param string $appName the name of the app |
|
71 | + * @param IRequest $request an instance of the request |
|
72 | + * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0 |
|
73 | + */ |
|
74 | + public function __construct($appName, |
|
75 | + IRequest $request) { |
|
76 | + $this->appName = $appName; |
|
77 | + $this->request = $request; |
|
78 | + |
|
79 | + // default responders |
|
80 | + $this->responders = [ |
|
81 | + 'json' => function ($data) { |
|
82 | + if ($data instanceof DataResponse) { |
|
83 | + $response = new JSONResponse( |
|
84 | + $data->getData(), |
|
85 | + $data->getStatus() |
|
86 | + ); |
|
87 | + $dataHeaders = $data->getHeaders(); |
|
88 | + $headers = $response->getHeaders(); |
|
89 | + // do not overwrite Content-Type if it already exists |
|
90 | + if (isset($dataHeaders['Content-Type'])) { |
|
91 | + unset($headers['Content-Type']); |
|
92 | + } |
|
93 | + $response->setHeaders(array_merge($dataHeaders, $headers)); |
|
94 | + |
|
95 | + if ($data->getETag() !== null) { |
|
96 | + $response->setETag($data->getETag()); |
|
97 | + } |
|
98 | + if ($data->getLastModified() !== null) { |
|
99 | + $response->setLastModified($data->getLastModified()); |
|
100 | + } |
|
101 | + |
|
102 | + return $response; |
|
103 | + } |
|
104 | + return new JSONResponse($data); |
|
105 | + } |
|
106 | + ]; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Parses an HTTP accept header and returns the supported responder type |
|
112 | + * @param string $acceptHeader |
|
113 | + * @param string $default |
|
114 | + * @return string the responder type |
|
115 | + * @since 7.0.0 |
|
116 | + * @since 9.1.0 Added default parameter |
|
117 | + */ |
|
118 | + public function getResponderByHTTPHeader($acceptHeader, $default = 'json') { |
|
119 | + $headers = explode(',', $acceptHeader); |
|
120 | + |
|
121 | + // return the first matching responder |
|
122 | + foreach ($headers as $header) { |
|
123 | + $header = strtolower(trim($header)); |
|
124 | + |
|
125 | + $responder = str_replace('application/', '', $header); |
|
126 | + |
|
127 | + if (array_key_exists($responder, $this->responders)) { |
|
128 | + return $responder; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + // no matching header return default |
|
133 | + return $default; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Registers a formatter for a type |
|
139 | + * @param string $format |
|
140 | + * @param \Closure $responder |
|
141 | + * @since 7.0.0 |
|
142 | + */ |
|
143 | + protected function registerResponder($format, \Closure $responder) { |
|
144 | + $this->responders[$format] = $responder; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Serializes and formats a response |
|
150 | + * @param mixed $response the value that was returned from a controller and |
|
151 | + * is not a Response instance |
|
152 | + * @param string $format the format for which a formatter has been registered |
|
153 | + * @throws \DomainException if format does not match a registered formatter |
|
154 | + * @return Response |
|
155 | + * @since 7.0.0 |
|
156 | + */ |
|
157 | + public function buildResponse($response, $format = 'json') { |
|
158 | + if (array_key_exists($format, $this->responders)) { |
|
159 | + $responder = $this->responders[$format]; |
|
160 | + |
|
161 | + return $responder($response); |
|
162 | + } |
|
163 | + throw new \DomainException('No responder registered for format '. |
|
164 | + $format . '!'); |
|
165 | + } |
|
166 | 166 | } |
@@ -42,67 +42,67 @@ |
||
42 | 42 | abstract class Middleware { |
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * This is being run in normal order before the controller is being |
|
47 | - * called which allows several modifications and checks |
|
48 | - * |
|
49 | - * @param Controller $controller the controller that is being called |
|
50 | - * @param string $methodName the name of the method that will be called on |
|
51 | - * the controller |
|
52 | - * @since 6.0.0 |
|
53 | - */ |
|
54 | - public function beforeController($controller, $methodName) { |
|
55 | - } |
|
45 | + /** |
|
46 | + * This is being run in normal order before the controller is being |
|
47 | + * called which allows several modifications and checks |
|
48 | + * |
|
49 | + * @param Controller $controller the controller that is being called |
|
50 | + * @param string $methodName the name of the method that will be called on |
|
51 | + * the controller |
|
52 | + * @since 6.0.0 |
|
53 | + */ |
|
54 | + public function beforeController($controller, $methodName) { |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * This is being run when either the beforeController method or the |
|
60 | - * controller method itself is throwing an exception. The middleware is |
|
61 | - * asked in reverse order to handle the exception and to return a response. |
|
62 | - * If the response is null, it is assumed that the exception could not be |
|
63 | - * handled and the error will be thrown again |
|
64 | - * |
|
65 | - * @param Controller $controller the controller that is being called |
|
66 | - * @param string $methodName the name of the method that will be called on |
|
67 | - * the controller |
|
68 | - * @param \Exception $exception the thrown exception |
|
69 | - * @throws \Exception the passed in exception if it can't handle it |
|
70 | - * @return Response a Response object in case that the exception was handled |
|
71 | - * @since 6.0.0 |
|
72 | - */ |
|
73 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
74 | - throw $exception; |
|
75 | - } |
|
58 | + /** |
|
59 | + * This is being run when either the beforeController method or the |
|
60 | + * controller method itself is throwing an exception. The middleware is |
|
61 | + * asked in reverse order to handle the exception and to return a response. |
|
62 | + * If the response is null, it is assumed that the exception could not be |
|
63 | + * handled and the error will be thrown again |
|
64 | + * |
|
65 | + * @param Controller $controller the controller that is being called |
|
66 | + * @param string $methodName the name of the method that will be called on |
|
67 | + * the controller |
|
68 | + * @param \Exception $exception the thrown exception |
|
69 | + * @throws \Exception the passed in exception if it can't handle it |
|
70 | + * @return Response a Response object in case that the exception was handled |
|
71 | + * @since 6.0.0 |
|
72 | + */ |
|
73 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
74 | + throw $exception; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * This is being run after a successful controllermethod call and allows |
|
80 | - * the manipulation of a Response object. The middleware is run in reverse order |
|
81 | - * |
|
82 | - * @param Controller $controller the controller that is being called |
|
83 | - * @param string $methodName the name of the method that will be called on |
|
84 | - * the controller |
|
85 | - * @param Response $response the generated response from the controller |
|
86 | - * @return Response a Response object |
|
87 | - * @since 6.0.0 |
|
88 | - */ |
|
89 | - public function afterController($controller, $methodName, Response $response) { |
|
90 | - return $response; |
|
91 | - } |
|
78 | + /** |
|
79 | + * This is being run after a successful controllermethod call and allows |
|
80 | + * the manipulation of a Response object. The middleware is run in reverse order |
|
81 | + * |
|
82 | + * @param Controller $controller the controller that is being called |
|
83 | + * @param string $methodName the name of the method that will be called on |
|
84 | + * the controller |
|
85 | + * @param Response $response the generated response from the controller |
|
86 | + * @return Response a Response object |
|
87 | + * @since 6.0.0 |
|
88 | + */ |
|
89 | + public function afterController($controller, $methodName, Response $response) { |
|
90 | + return $response; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * This is being run after the response object has been rendered and |
|
96 | - * allows the manipulation of the output. The middleware is run in reverse order |
|
97 | - * |
|
98 | - * @param Controller $controller the controller that is being called |
|
99 | - * @param string $methodName the name of the method that will be called on |
|
100 | - * the controller |
|
101 | - * @param string $output the generated output from a response |
|
102 | - * @return string the output that should be printed |
|
103 | - * @since 6.0.0 |
|
104 | - */ |
|
105 | - public function beforeOutput($controller, $methodName, $output) { |
|
106 | - return $output; |
|
107 | - } |
|
94 | + /** |
|
95 | + * This is being run after the response object has been rendered and |
|
96 | + * allows the manipulation of the output. The middleware is run in reverse order |
|
97 | + * |
|
98 | + * @param Controller $controller the controller that is being called |
|
99 | + * @param string $methodName the name of the method that will be called on |
|
100 | + * the controller |
|
101 | + * @param string $output the generated output from a response |
|
102 | + * @return string the output that should be printed |
|
103 | + * @since 6.0.0 |
|
104 | + */ |
|
105 | + public function beforeOutput($controller, $methodName, $output) { |
|
106 | + return $output; |
|
107 | + } |
|
108 | 108 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSNotFoundException extends OCSException { |
35 | - /** |
|
36 | - * OCSNotFoundException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSNotFoundException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSForbiddenException extends OCSException { |
35 | - /** |
|
36 | - * OCSForbiddenException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSForbiddenException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSBadRequestException extends OCSException { |
35 | - /** |
|
36 | - * OCSBadRequestException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSBadRequestException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->file = $file; |
52 | 52 | $this->setStatus($statusCode); |
53 | 53 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
54 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
54 | + $this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"'); |
|
55 | 55 | |
56 | 56 | $this->setETag($file->getEtag()); |
57 | 57 | $lastModified = new \DateTime(); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function callback(IOutput $output) { |
67 | 67 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
68 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | + $output->setHeader('Content-Length: '.$this->file->getSize()); |
|
69 | 69 | $output->setOutput($this->file->getContent()); |
70 | 70 | } |
71 | 71 | } |
@@ -32,40 +32,40 @@ |
||
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 | - parent::__construct(); |
|
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 | + parent::__construct(); |
|
49 | 49 | |
50 | - $this->file = $file; |
|
51 | - $this->setStatus($statusCode); |
|
52 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
50 | + $this->file = $file; |
|
51 | + $this->setStatus($statusCode); |
|
52 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | + $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
54 | 54 | |
55 | - $this->setETag($file->getEtag()); |
|
56 | - $lastModified = new \DateTime(); |
|
57 | - $lastModified->setTimestamp($file->getMTime()); |
|
58 | - $this->setLastModified($lastModified); |
|
59 | - } |
|
55 | + $this->setETag($file->getEtag()); |
|
56 | + $lastModified = new \DateTime(); |
|
57 | + $lastModified->setTimestamp($file->getMTime()); |
|
58 | + $this->setLastModified($lastModified); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function callback(IOutput $output) { |
|
66 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | - $output->setOutput($this->file->getContent()); |
|
69 | - } |
|
70 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function callback(IOutput $output) { |
|
66 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | + $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | + $output->setOutput($this->file->getContent()); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $this->filename = $filename; |
44 | 44 | $this->contentType = $contentType; |
45 | 45 | |
46 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
46 | + $this->addHeader('Content-Disposition', 'attachment; filename="'.$filename.'"'); |
|
47 | 47 | $this->addHeader('Content-Type', $contentType); |
48 | 48 | } |
49 | 49 | } |
@@ -30,22 +30,22 @@ |
||
30 | 30 | * @since 7.0.0 |
31 | 31 | */ |
32 | 32 | class DownloadResponse extends Response { |
33 | - private $filename; |
|
34 | - private $contentType; |
|
33 | + private $filename; |
|
34 | + private $contentType; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Creates a response that prompts the user to download the file |
|
38 | - * @param string $filename the name that the downloaded file should have |
|
39 | - * @param string $contentType the mimetype that the downloaded file should have |
|
40 | - * @since 7.0.0 |
|
41 | - */ |
|
42 | - public function __construct($filename, $contentType) { |
|
43 | - parent::__construct(); |
|
36 | + /** |
|
37 | + * Creates a response that prompts the user to download the file |
|
38 | + * @param string $filename the name that the downloaded file should have |
|
39 | + * @param string $contentType the mimetype that the downloaded file should have |
|
40 | + * @since 7.0.0 |
|
41 | + */ |
|
42 | + public function __construct($filename, $contentType) { |
|
43 | + parent::__construct(); |
|
44 | 44 | |
45 | - $this->filename = $filename; |
|
46 | - $this->contentType = $contentType; |
|
45 | + $this->filename = $filename; |
|
46 | + $this->contentType = $contentType; |
|
47 | 47 | |
48 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | - $this->addHeader('Content-Type', $contentType); |
|
50 | - } |
|
48 | + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | + $this->addHeader('Content-Type', $contentType); |
|
50 | + } |
|
51 | 51 | } |