1 | <?php |
||
20 | class Collections extends Nodes |
||
21 | { |
||
22 | /** |
||
23 | * @api {head} /api/v2/collections/:id/children children exists? |
||
24 | * @apiVersion 2.0.0 |
||
25 | * @apiName head |
||
26 | * @apiGroup Node\Collection |
||
27 | * @apiPermission none |
||
28 | * @apiDescription Check if collection has any children |
||
29 | * @apiUse _getNode |
||
30 | * |
||
31 | * @apiExample (cURL) example: |
||
32 | * curl -XHEAD "https://SERVER/api/v2/collections/children?id=544627ed3c58891f058b4686" |
||
33 | * curl -XHEAD "https://SERVER/api/v2/collections/544627ed3c58891f058b4686/children" |
||
34 | * curl -XHEAD "https://SERVER/api/v2/collections/children?p=/absolute/path/to/my/collection" |
||
35 | * |
||
36 | * @apiSuccessExample {json} Success-Response (Children exists): |
||
37 | * HTTP/1.1 204 Not Content |
||
38 | * |
||
39 | * @apiErrorExample {json} Error-Response (No children exists): |
||
40 | * HTTP/1.1 404 Not Found |
||
41 | * |
||
42 | * @param string $id |
||
43 | * @param string $p |
||
44 | * |
||
45 | * @return Response |
||
46 | */ |
||
47 | public function headChildren(?string $id = null, ?string $p = null): Response |
||
63 | |||
64 | /** |
||
65 | * @api {get} /api/v2/collections/:id/children Get children |
||
66 | * @apiVersion 2.0.0 |
||
67 | * @apiName getChildren |
||
68 | * @apiGroup Node\Collection |
||
69 | * @apiPermission none |
||
70 | * @apiDescription Find all children of a collection |
||
71 | * @apiUse _getNode |
||
72 | * @apiUse _nodeAttributes |
||
73 | * |
||
74 | * @apiExample (cURL) example: |
||
75 | * curl -XGET "https://SERVER/api/v2/collections/children?id=212323eeffe2322344224452&pretty" |
||
76 | * curl -XGET "https://SERVER/api/v2/collections/212323eeffe2322344224452/children?pretty&deleted=0" |
||
77 | * curl -XGET "https://SERVER/api/v2/collections/children?p=/absolute/path/to/my/collection&deleted=1" |
||
78 | * |
||
79 | * @apiParam (GET Parameter) {string[]} [attributes] Filter node attributes |
||
80 | * @apiParam (GET Parameter) {string[]} [filter] Filter nodes |
||
81 | * @apiParam (GET Parameter) {number} [deleted=0] Wherever include deleted nodes or not, possible values:</br> |
||
82 | * - 0 Exclude deleted</br> |
||
83 | * - 1 Only deleted</br> |
||
84 | * - 2 Include deleted</br> |
||
85 | * |
||
86 | * @apiSuccess (200 OK) {object[]} data Children |
||
87 | * @apiSuccessExample {json} Success-Response: |
||
88 | * HTTP/1.1 200 OK |
||
89 | * [ |
||
90 | * {..} |
||
91 | * ] |
||
92 | * |
||
93 | * @param string $id |
||
94 | * @param string $p |
||
95 | * @param int $deleted |
||
96 | * @param array $filter |
||
97 | * @param array $attributes |
||
98 | * @param int $offset |
||
99 | * @param int $limit |
||
100 | * |
||
101 | * @return Response |
||
102 | */ |
||
103 | public function getChildren( |
||
127 | |||
128 | /** |
||
129 | * @api {get} /api/v2/collections/:id/share Get Share ACL |
||
130 | * @apiVersion 2.0.0 |
||
131 | * @apiName getShare |
||
132 | * @apiGroup Node\Collection |
||
133 | * @apiPermission none |
||
134 | * @apiDescription Get share acl and share name |
||
135 | * @apiUse _getNode |
||
136 | * |
||
137 | * @apiExample (cURL) example: |
||
138 | * curl -XGET "https://SERVER/api/v2/collections/share?id=212323eeffe2322344224452&pretty" |
||
139 | * curl -XGET "https://SERVER/api/v2/collections/212323eeffe2322344224452/share?pretty" |
||
140 | * curl -XGET "https://SERVER/api/v2/collections/share?p=/absolute/path/to/my/collection&pretty" |
||
141 | * |
||
142 | * @apiSuccess (200 OK) {string} name Share name |
||
143 | * @apiSuccess (200 OK) {object[]} acl ACL rules |
||
144 | * @apiSuccess (200 OK) {string} acl.type Either group or user |
||
145 | * @apiSuccess (200 OK) {object} acl.role Role attributes |
||
146 | * @apiSuccess (200 OK) {string} acl.priv Permission to access share |
||
147 | * @apiSuccessExample {json} Success-Response: |
||
148 | * HTTP/1.1 200 OK |
||
149 | * { |
||
150 | * "name": "my share", |
||
151 | * "acl": [ |
||
152 | * { |
||
153 | * "type":"user", |
||
154 | * "role": { |
||
155 | * "id": "212323eeffe2322355224411", |
||
156 | * "name": "example" |
||
157 | * }, |
||
158 | * "privilege":"rw" |
||
159 | * } |
||
160 | * ] |
||
161 | *} |
||
162 | * |
||
163 | * @param RoleAttributeDecorator $role_decorator |
||
164 | * @param string $id |
||
165 | * @param string $p |
||
166 | * @param array $attributes |
||
167 | * |
||
168 | * @return Response |
||
169 | */ |
||
170 | public function getShare(RoleAttributeDecorator $role_decorator, ?string $id = null, ?string $p = null, array $attributes = []): Response |
||
189 | |||
190 | /** |
||
191 | * @api {post} /api/v2/collections/:id/share Create share |
||
192 | * @apiVersion 2.0.0 |
||
193 | * @apiGroup Node\Collection |
||
194 | * @apiPermission none |
||
195 | * @apiDescription Create a new share from an existing collection |
||
196 | * @apiUse _getNode |
||
197 | * @apiUse _writeAction |
||
198 | * |
||
199 | * @apiExample (cURL) example: |
||
200 | * curl -XPOST "https://SERVER/api/v2/collections/share?id=212323eeffe2322344224452&pretty" |
||
201 | * |
||
202 | * @apiParam (POST Parameter) {object[]} - ACL rules |
||
203 | * @apiParam (POST Parameter) {string} -.type user or group |
||
204 | * @apiParam (POST Parameter) {string} -.role Role id (user or group id) |
||
205 | * @apiParam (POST Parameter) {string} -.privilege Permission to access share, could be on of the following:</br> |
||
206 | * rw - READ/WRITE </br> |
||
207 | * r - READONLY </br> |
||
208 | * w+ - INBOX (Only Access to owned nodes) </br> |
||
209 | * m - Manage </br> |
||
210 | * d - DENY </br> |
||
211 | * |
||
212 | * @apiSuccess (201 Created) {string} id Node ID |
||
213 | * @apiSuccessExample {json} Success-Response (Created or Modified Share): |
||
214 | * HTTP/1.1 200 OK |
||
215 | * { |
||
216 | * "id": "212323eeffe2322344224452" |
||
217 | * } |
||
218 | * |
||
219 | * @param string $id |
||
220 | * @param string $p |
||
221 | * @param array $acl |
||
222 | * @param string $name |
||
223 | * |
||
224 | * @return Response |
||
225 | */ |
||
226 | public function postShare(array $acl, string $name, ?string $id = null, ?string $p = null): Response |
||
234 | |||
235 | /** |
||
236 | * @api {delete} /api/v2/collections/:id/share Delete share |
||
237 | * @apiVersion 2.0.0 |
||
238 | * @apiName deleteShare |
||
239 | * @apiGroup Node\Collection |
||
240 | * @apiPermission none |
||
241 | * @apiDescription Does only remove sharing options and transform a share back into a normal collection. |
||
242 | * There won't be any data loss after this action. All existing references would be removed automatically. |
||
243 | * @apiUse _getNode |
||
244 | * @apiUse _writeAction |
||
245 | * |
||
246 | * @apiExample (cURL) example: |
||
247 | * curl -XDELETE "https://SERVER/api/v2/collections/share?id=212323eeffe2322344224452" |
||
248 | * curl -XDELETE "https://SERVER/api/v2/collections/212323eeffe2322344224452/share" |
||
249 | * curl -XDELETE "https://SERVER/api/v2/collections/share?p=/absolute/path/to/my/collection" |
||
250 | * |
||
251 | * @apiSuccessExample {json} Success-Response: |
||
252 | * HTTP/1.1 204 No Content |
||
253 | * |
||
254 | * @param string $id |
||
255 | * @param string $p |
||
256 | * |
||
257 | * @return Response |
||
258 | */ |
||
259 | public function deleteShare(?string $id = null, ?string $p = null): Response |
||
266 | |||
267 | /** |
||
268 | * @api {post} /api/v2/collections/:id Create collection |
||
269 | * @apiVersion 2.0.0 |
||
270 | * @apiName post |
||
271 | * @apiGroup Node\Collection |
||
272 | * @apiPermission none |
||
273 | * @apiDescription Create a new collection. You can create a new collection combining a parent collection (id) and a name (name) |
||
274 | * or set an absolute path (p) to the new collection. Additionally it is possible to overwrite server generated timestamps like created or changed (attributes). |
||
275 | * Via the more advanced option filter (attributes.filter) you can create a special collection which can contain any nodes based on the given filter. |
||
276 | * For example a filter could be {mime: application/pdf}, therefore the collection would contain all files with mimetype application/pdf accessible by you. |
||
277 | * (Attention this can result in a slow server response since you could create a filter where no indexes exists, therefore the database engine needs to search the entire database) |
||
278 | * @apiUse _getNode |
||
279 | * @apiUse _conflictNode |
||
280 | * @apiUse _writeAction |
||
281 | * |
||
282 | * @apiExample (cURL) example: |
||
283 | * curl -XGET "https://SERVER/api/v2/collections?id=544627ef3c58891f058b468f&name=MyNewFolder&pretty" |
||
284 | * curl -XGET "https://SERVER/api/v2/collections/544627ef3c58891f058b468f?name=MyNewFolder&pretty" |
||
285 | * curl -XGET "https://SERVER/api/v2/collections/?p=/absolute/path/to/my/collection&name=MyNewFolder&pretty&conflict=2" |
||
286 | * |
||
287 | * @apiParam (GET Parameter) {string} id Either id or p (path) of a node must be given. |
||
288 | * @apiParam (GET Parameter) {string} p Either id or p (path) of a node must be given. If a path is given, no name must be set, |
||
289 | * the path must contain the name of the new collection. |
||
290 | * @apiParam (GET Parameter) {string} name A collection name must be set in conjuction with id, don't need to set with a path |
||
291 | * @apiParam (GET Parameter) {object} attributes Overwrite some attributes which are usually generated on the server |
||
292 | * @apiParam (GET Parameter) {number} attributes.created Set specific created timestamp (UNIX timestamp format) |
||
293 | * @apiParam (GET Parameter) {number} attributes.changed Set specific changed timestamp (UNIX timestamp format) |
||
294 | * @apiParam (GET Parameter) {number} attributes.destroy Set specific self-destroy timestamp (UNIX timestamp format) |
||
295 | * @apiParam (GET Parameter) {array} attributes.filter Set specific set of children instead just parent=this |
||
296 | * |
||
297 | * @apiSuccess (201 Created) {string} id Node ID |
||
298 | * @apiSuccessExample {json} Success-Response: |
||
299 | * HTTP/1.1 201 Created |
||
300 | * { |
||
301 | * "id": "544627ed3c58891f058b4682" |
||
302 | * } |
||
303 | * |
||
304 | * @param string $id |
||
305 | * @param string $p |
||
306 | * @param array $attributes |
||
307 | * @param int $conflict |
||
308 | * |
||
309 | * @return Response |
||
310 | */ |
||
311 | public function post( |
||
351 | } |
||
352 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: