1 | <?php |
||
25 | abstract class Controller |
||
26 | { |
||
27 | /** |
||
28 | * Filesystem. |
||
29 | * |
||
30 | * @var Filesystem |
||
31 | */ |
||
32 | protected $fs; |
||
33 | |||
34 | /** |
||
35 | * @apiDefine _getNode |
||
36 | * |
||
37 | * @apiParam (GET Parameter) {string} id Either id or p (path) of a node must be given. |
||
38 | * @apiParam (GET Parameter) {string} p Either id or p (path) of a node must be given. |
||
39 | * @apiError (General Error Response) {number} status Status Code |
||
40 | * @apiError (General Error Response) {object[]} data Error body |
||
41 | * @apiError (General Error Response) {string} data.error Exception |
||
42 | * @apiError (General Error Response) {string} data.message Message |
||
43 | * @apiError (General Error Response) {number} data.code Error code |
||
44 | * |
||
45 | * @apiErrorExample {json} Error-Response (Invalid Parameter): |
||
46 | * HTTP/1.1 400 Bad Request |
||
47 | * { |
||
48 | * "status": 400, |
||
49 | * "data": { |
||
50 | * "error": "Balloon\\Exception\\InvalidArgument", |
||
51 | * "message": "invalid node id specified", |
||
52 | * "code": 0 |
||
53 | * } |
||
54 | * } |
||
55 | * |
||
56 | * @apiErrorExample {json} Error-Response (Insufficient Access): |
||
57 | * HTTP/1.1 403 Forbidden |
||
58 | * { |
||
59 | * "status": 403, |
||
60 | * "data": { |
||
61 | * "error": "Balloon\\Exception\\Forbidden", |
||
62 | * "message": "not allowed to read node 51354d073c58891f058b4580", |
||
63 | * "code": 40 |
||
64 | * } |
||
65 | * } |
||
66 | * |
||
67 | * @apiErrorExample {json} Error-Response (Not found): |
||
68 | * HTTP/1.1 404 Not Found |
||
69 | * { |
||
70 | * "status": 404, |
||
71 | * "data": { |
||
72 | * "error": "Balloon\\Exception\\NotFound", |
||
73 | * "message": "node 51354d073c58891f058b4580 not found", |
||
74 | * "code": 49 |
||
75 | * } |
||
76 | * } |
||
77 | */ |
||
78 | |||
79 | /** |
||
80 | * @apiDefine _multiError |
||
81 | * |
||
82 | * @apiErrorExample {json} Error-Response (Multi node error): |
||
83 | * HTTP/1.1 400 Bad Request |
||
84 | * { |
||
85 | * "status": 400, |
||
86 | * "data": [ |
||
87 | * { |
||
88 | * id: "51354d073c58891f058b4580", |
||
89 | * name: "file.zip", |
||
90 | * error: "Balloon\\Exception\\Conflict", |
||
91 | * message: "node already exists", |
||
92 | * code: 30 |
||
93 | * } |
||
94 | * ] |
||
95 | * } |
||
96 | */ |
||
97 | |||
98 | /** |
||
99 | * @apiDefine _writeAction |
||
100 | * |
||
101 | * @apiErrorExample {json} Error-Response (Conflict): |
||
102 | * HTTP/1.1 400 Bad Request |
||
103 | * { |
||
104 | * "status": 400, |
||
105 | * "data": { |
||
106 | * "error": "Balloon\\Exception\\Conflict", |
||
107 | * "message": "a node called myname does already exists", |
||
108 | * "code": 17 |
||
109 | * } |
||
110 | * } |
||
111 | */ |
||
112 | |||
113 | /** |
||
114 | * @apiDefine _conflictNode |
||
115 | * @apiParam (GET Parameter) {number} [conflict=0] Decides how to handle a conflict if a node with the same name already exists at the destination. |
||
116 | * Possible values are:</br> |
||
117 | * - 0 No action</br> |
||
118 | * - 1 Automatically rename the node</br> |
||
119 | * - 2 Overwrite the destination (merge)</br> |
||
120 | */ |
||
121 | |||
122 | /** |
||
123 | * @apiDefine _getNodes |
||
124 | * |
||
125 | * @apiParam (GET Parameter) {string[]} id Either a single id as string or multiple as an array or a single p (path) as string or multiple paths as array must be given. |
||
126 | * @apiParam (GET Parameter) {string[]} p Either a single id as string or multiple as an array or a single p (path) as string or multiple paths as array must be given. |
||
127 | * @apiError (General Error Response) {number} status Status Code |
||
128 | * @apiError (General Error Response) {object[]} data Error body |
||
129 | * @apiError (General Error Response) {string} data.error Exception |
||
130 | * @apiError (General Error Response) {string} data.message Message |
||
131 | * @apiError (General Error Response) {number} data.code General error messages of type Balloon\\Exception do not usually have an error code |
||
132 | * |
||
133 | * @apiErrorExample {json} Error-Response (Invalid Parameter): |
||
134 | * HTTP/1.1 400 Bad Request |
||
135 | * { |
||
136 | * "status": 400, |
||
137 | * "data": { |
||
138 | * "error": "Balloon\\Exception\\InvalidArgument", |
||
139 | * "message": "invalid node id specified", |
||
140 | * "code": 0 |
||
141 | * } |
||
142 | * } |
||
143 | * |
||
144 | * @apiErrorExample {json} Error-Response (Insufficient Access): |
||
145 | * HTTP/1.1 403 Forbidden |
||
146 | * { |
||
147 | * "status": 403, |
||
148 | * "data": { |
||
149 | * "error": "Balloon\\Exception\\Forbidden", |
||
150 | * "message": "not allowed to read node 51354d073c58891f058b4580", |
||
151 | * "code": 40 |
||
152 | * } |
||
153 | * } |
||
154 | * |
||
155 | * @apiErrorExample {json} Error-Response (Not found): |
||
156 | * HTTP/1.1 404 Not Found |
||
157 | * { |
||
158 | * "status": 404, |
||
159 | * "data": { |
||
160 | * "error": "Balloon\\Exception\\NotFound", |
||
161 | * "message": "node 51354d073c58891f058b4580 not found", |
||
162 | * "code": 49 |
||
163 | * } |
||
164 | * } |
||
165 | */ |
||
166 | |||
167 | /** |
||
168 | * Do bulk operations. |
||
169 | * |
||
170 | * @param array|string $id |
||
171 | * @param array|string $p |
||
172 | */ |
||
173 | protected function bulk($id, $p, Closure $action): Response |
||
204 | |||
205 | /** |
||
206 | * Get node. |
||
207 | * |
||
208 | * @param string $id |
||
209 | * @param string $path |
||
210 | * @param string $class Force set node type |
||
211 | * @param bool $multiple Allow $id to be an array |
||
212 | * @param bool $allow_root Allow instance of root collection |
||
213 | * @param bool $deleted How to handle deleted node |
||
214 | */ |
||
215 | protected function _getNode( |
||
238 | |||
239 | /** |
||
240 | * Get nodes. |
||
241 | * |
||
242 | * @param string $id |
||
243 | * @param string $path |
||
244 | * @param string $class Force set node type |
||
245 | * @param bool $deleted How to handle deleted node |
||
246 | */ |
||
247 | protected function _getNodes( |
||
268 | } |
||
269 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.