Complex classes like Nodes often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Nodes, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 35 | class Nodes extends Controller |
||
| 36 | { |
||
| 37 | /** |
||
| 38 | * Filesystem. |
||
| 39 | * |
||
| 40 | * @var Filesystem |
||
| 41 | */ |
||
| 42 | protected $fs; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * LoggerInterface. |
||
| 46 | * |
||
| 47 | * @var LoggerInterface |
||
| 48 | */ |
||
| 49 | protected $logger; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Server. |
||
| 53 | * |
||
| 54 | * @var Server |
||
| 55 | */ |
||
| 56 | protected $server; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * User. |
||
| 60 | * |
||
| 61 | * @var User |
||
| 62 | */ |
||
| 63 | protected $user; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Node attribute decorator. |
||
| 67 | * |
||
| 68 | * @var NodeAttributeDecorator |
||
| 69 | */ |
||
| 70 | protected $node_decorator; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Initialize. |
||
| 74 | */ |
||
| 75 | public function __construct(Server $server, NodeAttributeDecorator $decorator, LoggerInterface $logger) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @api {head} /api/v2/nodes/:id Node exists? |
||
| 86 | * @apiVersion 2.0.0 |
||
| 87 | * @apiName head |
||
| 88 | * @apiGroup Node |
||
| 89 | * @apiPermission none |
||
| 90 | * @apiDescription Check if a node exists. Per default deleted nodes are ignore which means it will |
||
| 91 | * return a 404 if a deleted node is requested. You can change this behaviour via the deleted parameter. |
||
| 92 | * @apiUse _getNode |
||
| 93 | * |
||
| 94 | * @apiExample (cURL) example: |
||
| 95 | * curl -XHEAD "https://SERVER/api/v2/node?id=544627ed3c58891f058b4686" |
||
| 96 | * curl -XHEAD "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686" |
||
| 97 | * curl -XHEAD "https://SERVER/api/v2/node?p=/absolute/path/to/my/node" |
||
| 98 | * |
||
| 99 | * @apiParam (GET Parameter) {number} [deleted=0] Wherever include deleted node or not, possible values:</br> |
||
| 100 | * - 0 Exclude deleted</br> |
||
| 101 | * - 1 Only deleted</br> |
||
| 102 | * - 2 Include deleted</br> |
||
| 103 | * |
||
| 104 | * @apiSuccessExample {json} Success-Response (Node does exist): |
||
| 105 | * HTTP/1.1 200 OK |
||
| 106 | * |
||
| 107 | * @apiSuccessExample {json} Success-Response (Node does not exist): |
||
| 108 | * HTTP/1.1 404 Not Found |
||
| 109 | * |
||
| 110 | * @param string $id |
||
| 111 | * @param string $p |
||
| 112 | */ |
||
| 113 | public function head(?string $id = null, ?string $p = null, int $deleted = 0): Response |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @api {post} /api/v2/nodes/:id/undelete Restore node |
||
| 131 | * @apiVersion 2.0.0 |
||
| 132 | * @apiName postUndelete |
||
| 133 | * @apiGroup Node |
||
| 134 | * @apiPermission none |
||
| 135 | * @apiDescription Undelete (Restore from trash) a single node or multiple ones. |
||
| 136 | * @apiUse _getNodes |
||
| 137 | * @apiUse _conflictNode |
||
| 138 | * @apiUse _multiError |
||
| 139 | * @apiUse _writeAction |
||
| 140 | * |
||
| 141 | * @apiExample (cURL) example: |
||
| 142 | * curl -XPOST "https://SERVER/api/v2/nodes/undelete?id[]=544627ed3c58891f058b4686&id[]=544627ed3c58891f058b46865&pretty" |
||
| 143 | * curl -XPOST "https://SERVER/api/v2/nodes/undelete?id=544627ed3c58891f058b4686?pretty" |
||
| 144 | * curl -XPOST "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686/undelete?conflict=2" |
||
| 145 | * curl -XPOST "https://SERVER/api/v2/nodes/undelete?p=/absolute/path/to/my/node&conflict=0&move=1&destid=544627ed3c58891f058b46889" |
||
| 146 | * |
||
| 147 | * @apiParam (GET Parameter) {string} [destid] Either destid or destp (path) of the new parent collection node must be given. |
||
| 148 | * @apiParam (GET Parameter) {string} [destp] Either destid or destp (path) of the new parent collection node must be given. |
||
| 149 | * |
||
| 150 | * @apiSuccessExample {json} Success-Response (conflict=1): |
||
| 151 | * HTTP/1.1 200 OK |
||
| 152 | * { |
||
| 153 | * "id": "544627ed3c58891f058b4686", |
||
| 154 | * "name": "renamed (xy23)" |
||
| 155 | * } |
||
| 156 | * |
||
| 157 | * @param array|string $id |
||
| 158 | * @param array|string $p |
||
| 159 | * @param string $destid |
||
| 160 | * @param string $destp |
||
| 161 | */ |
||
| 162 | public function postUndelete( |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @api {get} /api/v2/nodes/:id/content Download stream |
||
| 200 | * @apiVersion 2.0.0 |
||
| 201 | * @apiName getContent |
||
| 202 | * @apiGroup Node |
||
| 203 | * @apiPermission none |
||
| 204 | * @apiDescription Download node contents. Collections are zipped during streaming. |
||
| 205 | * @apiUse _getNode |
||
| 206 | * @apiParam (GET Parameter) {boolean} [download=false] Force download file (Content-Disposition: attachment HTTP header) |
||
| 207 | * |
||
| 208 | * @apiExample (cURL) example: |
||
| 209 | * curl -XGET "https://SERVER/api/v2/node?id=544627ed3c58891f058b4686" > myfile.txt |
||
| 210 | * curl -XGET "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686" > myfile.txt |
||
| 211 | * curl -XGET "https://SERVER/api/v2/node?p=/absolute/path/to/my/collection" > folder.zip |
||
| 212 | * |
||
| 213 | * @apiSuccessExample {binary} Success-Response: |
||
| 214 | * HTTP/1.1 200 OK |
||
| 215 | * |
||
| 216 | * @apiErrorExample {json} Error-Response (Invalid offset): |
||
| 217 | * HTTP/1.1 400 Bad Request |
||
| 218 | * { |
||
| 219 | * "status": 400, |
||
| 220 | * "data": { |
||
| 221 | * "error": "Balloon\\Exception\\Conflict", |
||
| 222 | * "message": "invalid offset requested", |
||
| 223 | * "code": 277 |
||
| 224 | * } |
||
| 225 | * } |
||
| 226 | * |
||
| 227 | * @param array|string $id |
||
| 228 | * @param array|string $p |
||
| 229 | */ |
||
| 230 | public function getContent( |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @apiDefine _nodeAttributes |
||
| 252 | * |
||
| 253 | * @apiSuccess (200 OK) {string} id Unique node id |
||
| 254 | * @apiSuccess (200 OK) {string} name Name |
||
| 255 | * @apiSuccess (200 OK) {string} hash MD5 content checksum (file only) |
||
| 256 | * @apiSuccess (200 OK) {object} meta Extended meta attributes |
||
| 257 | * @apiSuccess (200 OK) {string} meta.description UTF-8 Text Description |
||
| 258 | * @apiSuccess (200 OK) {string} meta.color Color Tag (HEX) (Like: #000000) |
||
| 259 | * @apiSuccess (200 OK) {string} meta.author Author |
||
| 260 | * @apiSuccess (200 OK) {string} meta.mail Mail contact address |
||
| 261 | * @apiSuccess (200 OK) {string} meta.license License |
||
| 262 | * @apiSuccess (200 OK) {string} meta.copyright Copyright string |
||
| 263 | * @apiSuccess (200 OK) {string[]} meta.tags Search Tags |
||
| 264 | * @apiSuccess (200 OK) {number} size Size in bytes (file only), number of children if collection |
||
| 265 | * @apiSuccess (200 OK) {string} mime Mime type |
||
| 266 | * @apiSuccess (200 OK) {boolean} sharelink Is node shared? |
||
| 267 | * @apiSuccess (200 OK) {number} version File version (file only) |
||
| 268 | * @apiSuccess (200 OK) {mixed} deleted Is boolean false if not deleted, if deleted it contains a deleted timestamp |
||
| 269 | * @apiSuccess (200 OK) {string} deleted ISO8601 timestamp, only set if node is deleted |
||
| 270 | * @apiSuccess (200 OK) {string} changed ISO8601 timestamp |
||
| 271 | * @apiSuccess (200 OK) {string} created ISO8601 timestamp |
||
| 272 | * @apiSuccess (200 OK) {string} destroy ISO8601 timestamp, only set if node has a destroy timestamp set |
||
| 273 | * @apiSuccess (200 OK) {boolean} share Node is shared |
||
| 274 | * @apiSuccess (200 OK) {boolean} directory Is true if the node is a collection |
||
| 275 | * @apiSuccess (200 OK) {string} access Access permission for the authenticated user (d/r/rw/m) |
||
| 276 | * @apiSuccess (200 OK) {object} shareowner Share owner |
||
| 277 | * @apiSuccess (200 OK) {object} parent Parent node |
||
| 278 | * @apiSuccess (200 OK) {string} path Absolute node path |
||
| 279 | * @apiSuccess (200 OK) {string} filter Node is filtered (collection only) |
||
| 280 | * @apiSuccess (200 OK) {boolean} readonly Readonly |
||
| 281 | * |
||
| 282 | * @apiParam (GET Parameter) {string[]} [attributes] Filter attributes |
||
| 283 | * |
||
| 284 | * @param null|mixed $id |
||
| 285 | * @param null|mixed $p |
||
| 286 | */ |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @api {get} /api/v2/nodes/:id Get attributes |
||
| 290 | * @apiVersion 2.0.0 |
||
| 291 | * @apiName get |
||
| 292 | * @apiGroup Node |
||
| 293 | * @apiPermission none |
||
| 294 | * @apiDescription Get attributes from one or multiple nodes |
||
| 295 | * @apiUse _getNode |
||
| 296 | * @apiUse _nodeAttributes |
||
| 297 | * |
||
| 298 | * @apiParam (GET Parameter) {string[]} [attributes] Filter attributes, per default only a bunch of attributes would be returned, if you |
||
| 299 | * need other attributes you have to request them (for example "path") |
||
| 300 | * |
||
| 301 | * @apiExample (cURL) example: |
||
| 302 | * curl -XGET "https://SERVER/api/v2/node?id=544627ed3c58891f058b4686&pretty" |
||
| 303 | * curl -XGET "https://SERVER/api/v2/node?id=544627ed3c58891f058b4686&attributes[0]=name&attributes[1]=deleted&pretty" |
||
| 304 | * curl -XGET "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686?pretty" |
||
| 305 | * curl -XGET "https://SERVER/api/v2/node?p=/absolute/path/to/my/node&pretty" |
||
| 306 | * |
||
| 307 | * @apiSuccessExample {json} Success-Response: |
||
| 308 | * HTTP/1.1 200 OK |
||
| 309 | * { |
||
| 310 | * "id": "544627ed3c58891f058b4686", |
||
| 311 | * "name": "api.php", |
||
| 312 | * "hash": "a77f23ed800fd7a600a8c2cfe8cc370b", |
||
| 313 | * "meta": { |
||
| 314 | * "license": "GPLv3" |
||
| 315 | * }, |
||
| 316 | * "size": 178, |
||
| 317 | * "mime": "text\/plain", |
||
| 318 | * "sharelink": true, |
||
| 319 | * "version": 1, |
||
| 320 | * "changed": "2007-08-31T16:47+00:00", |
||
| 321 | * "created": "2007-08-31T16:47+00:00", |
||
| 322 | * "share": false, |
||
| 323 | * "directory": false |
||
| 324 | * } |
||
| 325 | * |
||
| 326 | * @param array|string $id |
||
| 327 | * @param array|string $p |
||
| 328 | */ |
||
| 329 | public function get($id = null, $p = null, int $deleted = 0, array $query = [], array $attributes = [], int $offset = 0, int $limit = 20): Response |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @api {get} /api/v2/nodes/:id/parents Get parent nodes |
||
| 359 | * @apiVersion 2.0.0 |
||
| 360 | * @apiName getParents |
||
| 361 | * @apiGroup Node |
||
| 362 | * @apiPermission none |
||
| 363 | * @apiDescription Get system attributes of all parent nodes. The hirarchy of all parent nodes is ordered in a |
||
| 364 | * single level array beginning with the collection on the highest level. |
||
| 365 | * @apiUse _getNode |
||
| 366 | * @apiUse _nodeAttributes |
||
| 367 | * |
||
| 368 | * @apiParam (GET Parameter) {boolean} [self=true] Include requested collection itself at the end of the list (Will be ignored if the requested node is a file) |
||
| 369 | * |
||
| 370 | * @apiExample (cURL) example: |
||
| 371 | * curl -XGET "https://SERVER/api/v2/nodes/parents?id=544627ed3c58891f058b4686&pretty" |
||
| 372 | * curl -XGET "https://SERVER/api/v2/nodes/parents?id=544627ed3c58891f058b4686&attributes[0]=name&attributes[1]=deleted&pretty" |
||
| 373 | * curl -XGET "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686/parents?pretty&self=1" |
||
| 374 | * curl -XGET "https://SERVER/api/v2/nodes/parents?p=/absolute/path/to/my/node&self=1" |
||
| 375 | * |
||
| 376 | * @apiSuccessExample {json} Success-Response: |
||
| 377 | * HTTP/1.1 200 OK |
||
| 378 | * [ |
||
| 379 | * { |
||
| 380 | * "id": "544627ed3c58891f058bbbaa", |
||
| 381 | * "name": "rootdir", |
||
| 382 | * "meta": {}, |
||
| 383 | * "size": 1, |
||
| 384 | * "mime": "inode/directory", |
||
| 385 | * "created": "2007-08-31T16:47+00:00", |
||
| 386 | * "changed": "2007-08-31T16:47+00:00", |
||
| 387 | * "destroy": "2020-08-31T16:47+00:00", |
||
| 388 | * "share": false, |
||
| 389 | * "directory": true |
||
| 390 | * }, |
||
| 391 | * { |
||
| 392 | * "id": "544627ed3c58891f058b46cc", |
||
| 393 | * "name": "parentdir", |
||
| 394 | * "meta": {}, |
||
| 395 | * "size": 3, |
||
| 396 | * "mime": "inode/directory", |
||
| 397 | * "created": "2007-08-31T16:47+00:00", |
||
| 398 | * "changed": "2007-08-31T16:47+00:00", |
||
| 399 | * "share": false, |
||
| 400 | * "directory": true |
||
| 401 | * } |
||
| 402 | * ] |
||
| 403 | * |
||
| 404 | * @param string $id |
||
| 405 | * @param string $p |
||
| 406 | */ |
||
| 407 | public function getParents(?string $id = null, ?string $p = null, array $attributes = [], bool $self = false): Response |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @api {patch} /api/v2/nodes/:id Change attributes |
||
| 426 | * @apiVersion 2.0.0 |
||
| 427 | * @apiName patch |
||
| 428 | * @apiGroup Node |
||
| 429 | * @apiPermission none |
||
| 430 | * @apiDescription Change attributes |
||
| 431 | * @apiUse _getNodes |
||
| 432 | * @apiUse _multiError |
||
| 433 | * |
||
| 434 | * @apiParam (GET Parameter) {string} [name] Rename node, the characters (\ < > : " / * ? |) (without the "()") are not allowed to use within a node name. |
||
| 435 | * @apiParam (GET Parameter) {boolean} [readonly] Mark node as readonly |
||
| 436 | * @apiParam (GET Parameter) {object} [filter] Custom collection filter (Collection only) |
||
| 437 | * @apiParam (GET Parameter) {string} [meta.description] UTF-8 Text Description - Can contain anything as long as it is a string |
||
| 438 | * @apiParam (GET Parameter) {string} [meta.color] Color Tag - Can contain anything as long as it is a string |
||
| 439 | * @apiParam (GET Parameter) {string} [meta.author] Author - Can contain anything as long as it is a string |
||
| 440 | * @apiParam (GET Parameter) {string} [meta.mail] Mail contact address - Can contain anything as long as it is a string |
||
| 441 | * @apiParam (GET Parameter) {string} [meta.license] License - Can contain anything as long as it is a string |
||
| 442 | * @apiParam (GET Parameter) {string} [meta.copyright] Copyright string - Can contain anything as long as it is a string |
||
| 443 | * @apiParam (GET Parameter) {string[]} [meta.tags] Tags - Must be an array full of strings |
||
| 444 | * |
||
| 445 | * @apiExample (cURL) example: |
||
| 446 | * curl -XPATCH "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686?name=example" |
||
| 447 | * |
||
| 448 | * @apiSuccessExample {json} Success-Response: |
||
| 449 | * HTTP/1.1 200 |
||
| 450 | * |
||
| 451 | * @param array|string $id |
||
| 452 | * @param array|string $p |
||
| 453 | */ |
||
| 454 | public function patch(?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, ?array $acl = null, ?string $id = null, ?string $p = null): Response |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @api {post} /api/v2/nodes/:id/clone Clone node |
||
| 496 | * @apiVersion 2.0.0 |
||
| 497 | * @apiName postClone |
||
| 498 | * @apiGroup Node |
||
| 499 | * @apiPermission none |
||
| 500 | * @apiDescription Clone a node |
||
| 501 | * @apiUse _getNode |
||
| 502 | * @apiUse _conflictNode |
||
| 503 | * @apiUse _multiError |
||
| 504 | * @apiUse _writeAction |
||
| 505 | * |
||
| 506 | * @apiParam (GET Parameter) {string} [destid] Either destid or destp (path) of the new parent collection node must be given. |
||
| 507 | * @apiParam (GET Parameter) {string} [destp] Either destid or destp (path) of the new parent collection node must be given. |
||
| 508 | * |
||
| 509 | * @apiExample (cURL) example: |
||
| 510 | * curl -XPOST "https://SERVER/api/v2/nodes/clone?id=544627ed3c58891f058b4686&dest=544627ed3c58891f058b4676" |
||
| 511 | * curl -XPOST "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686/clone?dest=544627ed3c58891f058b4676&conflict=2" |
||
| 512 | * curl -XPOST "https://SERVER/api/v2/nodes/clone?p=/absolute/path/to/my/node&conflict=0&destp=/new/parent" |
||
| 513 | * |
||
| 514 | * @apiSuccessExample {json} Success-Response: |
||
| 515 | * HTTP/1.1 201 Created |
||
| 516 | * |
||
| 517 | * @apiSuccessExample {json} Success-Response: |
||
| 518 | * HTTP/1.1 200 OK |
||
| 519 | * |
||
| 520 | * @param array|string $id |
||
| 521 | * @param array|string $id |
||
| 522 | * @param array|string $p |
||
| 523 | * @param string $destid |
||
| 524 | * @param string $destp |
||
| 525 | */ |
||
| 526 | public function postClone( |
||
| 551 | |||
| 552 | /** |
||
| 553 | * @api {post} /api/v2/nodes/:id/move Move node |
||
| 554 | * @apiVersion 2.0.0 |
||
| 555 | * @apiName postMove |
||
| 556 | * @apiGroup Node |
||
| 557 | * @apiPermission none |
||
| 558 | * @apiDescription Move node |
||
| 559 | * @apiUse _getNodes |
||
| 560 | * @apiUse _conflictNode |
||
| 561 | * @apiUse _multiError |
||
| 562 | * @apiUse _writeAction |
||
| 563 | * |
||
| 564 | * @apiParam (GET Parameter) {string} [destid] Either destid or destp (path) of the new parent collection node must be given. |
||
| 565 | * @apiParam (GET Parameter) {string} [destp] Either destid or destp (path) of the new parent collection node must be given. |
||
| 566 | * |
||
| 567 | * @apiExample (cURL) example: |
||
| 568 | * curl -XPOST "https://SERVER/api/v2/nodes/move?id=544627ed3c58891f058b4686?destid=544627ed3c58891f058b4655" |
||
| 569 | * curl -XPOST "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686/move?destid=544627ed3c58891f058b4655" |
||
| 570 | * curl -XPOST "https://SERVER/api/v2/nodes/move?p=/absolute/path/to/my/node&destp=/new/parent&conflict=1 |
||
| 571 | * |
||
| 572 | * @apiSuccessExample {json} Success-Response: |
||
| 573 | * HTTP/1.1 204 No Content |
||
| 574 | * |
||
| 575 | * @apiSuccessExample {json} Success-Response (conflict=1): |
||
| 576 | * HTTP/1.1 200 OK |
||
| 577 | * { |
||
| 578 | * "status":200, |
||
| 579 | * "data": "renamed (xy23)" |
||
| 580 | * } |
||
| 581 | * |
||
| 582 | * @param array|string $id |
||
| 583 | * @param array|string $p |
||
| 584 | * @param string $destid |
||
| 585 | * @param string $destp |
||
| 586 | */ |
||
| 587 | public function postMove( |
||
| 612 | |||
| 613 | /** |
||
| 614 | * @api {delete} /api/v2/nodes/:id Delete node |
||
| 615 | * @apiVersion 2.0.0 |
||
| 616 | * @apiName delete |
||
| 617 | * @apiGroup Node |
||
| 618 | * @apiPermission none |
||
| 619 | * @apiDescription Delete node |
||
| 620 | * @apiUse _getNodes |
||
| 621 | * @apiUse _multiError |
||
| 622 | * @apiUse _writeAction |
||
| 623 | * |
||
| 624 | * @apiParam (GET Parameter) {boolean} [force=false] Force flag need to be set to delete a node from trash (node must have the deleted flag) |
||
| 625 | * @apiParam (GET Parameter) {boolean} [ignore_flag=false] If both ignore_flag and force_flag were set, the node will be deleted completely |
||
| 626 | * @apiParam (GET Parameter) {number} [at] Has to be a valid unix timestamp if so the node will destroy itself at this specified time instead immediatly |
||
| 627 | * |
||
| 628 | * @apiExample (cURL) example: |
||
| 629 | * curl -XDELETE "https://SERVER/api/v2/node?id=544627ed3c58891f058b4686" |
||
| 630 | * curl -XDELETE "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686?force=1&ignore_flag=1" |
||
| 631 | * curl -XDELETE "https://SERVER/api/v2/node?p=/absolute/path/to/my/node" |
||
| 632 | * |
||
| 633 | * @apiSuccessExample {json} Success-Response: |
||
| 634 | * HTTP/1.1 204 No Content |
||
| 635 | * |
||
| 636 | * @param array|string $id |
||
| 637 | * @param array|string $p |
||
| 638 | * @param int $at |
||
| 639 | */ |
||
| 640 | public function delete( |
||
| 668 | |||
| 669 | /** |
||
| 670 | * @api {get} /api/v2/nodes/trash Get trash |
||
| 671 | * @apiName getTrash |
||
| 672 | * @apiVersion 2.0.0 |
||
| 673 | * @apiGroup Node |
||
| 674 | * @apiPermission none |
||
| 675 | * @apiDescription A similar endpoint to /api/v2/nodes/query filer={'deleted': {$type: 9}] but instead returning all deleted |
||
| 676 | * nodes (including children which are deleted as well) this enpoint only returns the first deleted node from every subtree) |
||
| 677 | * @apiUse _nodeAttributes |
||
| 678 | * |
||
| 679 | * @apiExample (cURL) example: |
||
| 680 | * curl -XGET https://SERVER/api/v2/nodes/trash?pretty |
||
| 681 | * |
||
| 682 | * @apiParam (GET Parameter) {string[]} [attributes] Filter node attributes |
||
| 683 | * |
||
| 684 | * @apiSuccess (200 OK) {object[]} - List of deleted nodes |
||
| 685 | * @apiSuccessExample {json} Success-Response: |
||
| 686 | * HTTP/1.1 200 OK |
||
| 687 | * [ |
||
| 688 | * { |
||
| 689 | * } |
||
| 690 | * ] |
||
| 691 | */ |
||
| 692 | public function getTrash(array $attributes = [], int $offset = 0, int $limit = 20): Response |
||
| 725 | |||
| 726 | /** |
||
| 727 | * @api {get} /api/v2/nodes/delta Get delta |
||
| 728 | * @apiVersion 2.0.0 |
||
| 729 | * @apiName getDelta |
||
| 730 | * @apiGroup Node |
||
| 731 | * @apiPermission none |
||
| 732 | * @apiUse _getNode |
||
| 733 | * |
||
| 734 | * @apiDescription Use this method to request a delta feed with all changes on the server (or) a snapshot of the server state. |
||
| 735 | * since the state of the submited cursor. If no cursor was submited the server will create one which can than be used to request any further deltas. |
||
| 736 | * If has_more is TRUE you need to request /delta immediatly again to |
||
| 737 | * receive the next bunch of deltas. If has_more is FALSE you should wait at least 120s seconds before any further requests to the |
||
| 738 | * api endpoint. You can also specify additional node attributes with the $attributes paramter or request the delta feed only for a specific node (see Get Attributes for that). |
||
| 739 | * If reset is TRUE you have to clean your local state because you will receive a snapshot of the server state, it is the same as calling the /delta endpoint |
||
| 740 | * without a cursor. reset could be TRUE if there was an account maintenance or a simialar case. |
||
| 741 | * You can request a different limit as well but be aware that the number of nodes could be slighty different from your requested limit. |
||
| 742 | * If requested with parameter id or p the delta gets generated recursively from the node given. |
||
| 743 | * |
||
| 744 | * @apiParam (GET Parameter) {number} [limit=250] Limit the number of delta entries, if too low you have to call this endpoint more often since has_more would be true more often |
||
| 745 | * @apiParam (GET Parameter) {string[]} [attributes] Filter attributes, per default not all attributes would be returned |
||
| 746 | * @apiParam (GET Parameter) {string} [cursor=null] Set a cursor to rquest next nodes within delta processing |
||
| 747 | * |
||
| 748 | * @apiExample (cURL) example: |
||
| 749 | * curl -XGET "https://SERVER/api/v2/nodes/delta?pretty" |
||
| 750 | * |
||
| 751 | * @apiSuccess (200 OK) {boolean} reset If true the local state needs to be reseted, is alway TRUE during |
||
| 752 | * the first request to /delta without a cursor or in special cases like server or account maintenance |
||
| 753 | * @apiSuccess (200 OK) {string} cursor The cursor needs to be stored and reused to request further deltas |
||
| 754 | * @apiSuccess (200 OK) {boolean} has_more If has_more is TRUE /delta can be requested immediatly after the last request |
||
| 755 | * to receive further delta. If it is FALSE we should wait at least 120 seconds before any further delta requests to the api endpoint |
||
| 756 | * @apiSuccess (200 OK) {object[]} nodes Node list to process |
||
| 757 | * @apiSuccessExample {json} Success-Response: |
||
| 758 | * HTTP/1.1 200 OK |
||
| 759 | * { |
||
| 760 | * "reset": false, |
||
| 761 | * "cursor": "aW5pdGlhbHwxMDB8NTc1YTlhMGIzYzU4ODkwNTE0OGI0NTZifDU3NWE5YTBiM2M1ODg5MDUxNDhiNDU2Yw==", |
||
| 762 | * "has_more": false, |
||
| 763 | * "nodes": [ |
||
| 764 | * { |
||
| 765 | * "id": "581afa783c5889ad7c8b4572", |
||
| 766 | * "deleted": " 2008-08-31T16:47+00:00", |
||
| 767 | * "changed": "2007-08-31T16:47+00:00", |
||
| 768 | * "path": "\/AAA\/AL", |
||
| 769 | * "directory": true |
||
| 770 | * }, |
||
| 771 | * { |
||
| 772 | * "id": "581afa783c5889ad7c8b3dcf", |
||
| 773 | * "created": "2007-08-31T16:47+00:00", |
||
| 774 | * "changed": "2007-09-28T12:33+00:00", |
||
| 775 | * "path": "\/AL", |
||
| 776 | * "directory": true |
||
| 777 | * } |
||
| 778 | * ] |
||
| 779 | * } |
||
| 780 | * |
||
| 781 | * @param string $id |
||
| 782 | * @param string $p |
||
| 783 | * @param string $cursor |
||
| 784 | */ |
||
| 785 | public function getDelta( |
||
| 810 | |||
| 811 | /** |
||
| 812 | * @api {get} /api/v2/nodes/:id/event-log Event log |
||
| 813 | * @apiVersion 2.0.0 |
||
| 814 | * @apiName getEventLog |
||
| 815 | * @apiGroup Node |
||
| 816 | * @apiPermission none |
||
| 817 | * @apiUse _getNode |
||
| 818 | * @apiDescription Get detailed event log |
||
| 819 | * Request all modifications which are made by the user himself or share members. |
||
| 820 | * Possible operations are the follwing: |
||
| 821 | * - deleteCollectionReference |
||
| 822 | * - deleteCollectionShare |
||
| 823 | * - deleteCollection |
||
| 824 | * - addCollection |
||
| 825 | * - addFile |
||
| 826 | * - addCollectionShare |
||
| 827 | * - addCollectionReference |
||
| 828 | * - undeleteFile |
||
| 829 | * - undeleteCollectionReference |
||
| 830 | * - undeleteCollectionShare |
||
| 831 | * - restoreFile |
||
| 832 | * - renameFile |
||
| 833 | * - renameCollection |
||
| 834 | * - renameCollectionShare |
||
| 835 | * - renameCollectionRFeference |
||
| 836 | * - copyFile |
||
| 837 | * - copyCollection |
||
| 838 | * - copyCollectionShare |
||
| 839 | * - copyCollectionRFeference |
||
| 840 | * - moveFile |
||
| 841 | * - moveCollection |
||
| 842 | * - moveCollectionReference |
||
| 843 | * - moveCollectionShare |
||
| 844 | * |
||
| 845 | * @apiExample (cURL) example: |
||
| 846 | * curl -XGET "https://SERVER/api/v2/nodes/event-log?pretty" |
||
| 847 | * curl -XGET "https://SERVER/api/v2/nodes/event-log?id=544627ed3c58891f058b4686&pretty" |
||
| 848 | * curl -XGET "https://SERVER/api/v2/nodes/544627ed3c58891f058b4686/event-log?pretty&limit=10" |
||
| 849 | * curl -XGET "https://SERVER/api/v2/nodes/event-log?p=/absolute/path/to/my/node&pretty" |
||
| 850 | * |
||
| 851 | * @apiParam (GET Parameter) {number} [limit=100] Sets limit of events to be returned |
||
| 852 | * @apiParam (GET Parameter) {number} [skip=0] How many events are skiped (useful for paging) |
||
| 853 | * |
||
| 854 | * @apiSuccess (200 OK) {object[]} - List of events |
||
| 855 | * @apiSuccess (200 OK) {number} -.event Event ID |
||
| 856 | * @apiSuccess (200 OK) {object} -.timestamp ISO8601 timestamp when the event occured |
||
| 857 | * @apiSuccess (200 OK) {string} -.operation event operation (like addCollection, deleteFile, ...) |
||
| 858 | * @apiSuccess (200 OK) {object} -.parent Parent node object at the time of the event |
||
| 859 | * @apiSuccess (200 OK) {object} -.previous Previous state of actual data which has been modified during an event, can contain either version, name or parent |
||
| 860 | * @apiSuccess (200 OK) {number} -.previous.version Version at the time before the event |
||
| 861 | * @apiSuccess (200 OK) {string} -.previous.name Name at the time before the event |
||
| 862 | * @apiSuccess (200 OK) {object} -.previous.parent Parent node object at the time before the event |
||
| 863 | * @apiSuccess (200 OK) {object} -.share shared collection object at the time of the event (If the node was part of a share) |
||
| 864 | * @apiSuccess (200 OK) {string} -.name Name of the node at the time of the event |
||
| 865 | * @apiSuccess (200 OK) {object} -.node Current node object |
||
| 866 | * @apiSuccess (200 OK) {object} -.user User who executed an event |
||
| 867 | * |
||
| 868 | * @apiSuccessExample {json} Success-Response: |
||
| 869 | * HTTP/1.1 200 OK |
||
| 870 | * [ |
||
| 871 | * { |
||
| 872 | * "id": "57628e523c5889026f8b4570", |
||
| 873 | * "timestamp": " 2018-01-02T13:22+00:00", |
||
| 874 | * "operation": "restoreFile", |
||
| 875 | * "name": "file.txt", |
||
| 876 | * "previous": { |
||
| 877 | * "version": 16 |
||
| 878 | * }, |
||
| 879 | * "node": { |
||
| 880 | * "id": "558c0b273c588963078b457a", |
||
| 881 | * "name": "3dddsceheckfile.txt", |
||
| 882 | * "deleted": false |
||
| 883 | * }, |
||
| 884 | * "parent": null, |
||
| 885 | * "user": { |
||
| 886 | * "id": "54354cb63c58891f058b457f", |
||
| 887 | * "username": "example" |
||
| 888 | * } |
||
| 889 | * } |
||
| 890 | * ] |
||
| 891 | * |
||
| 892 | * @param string $id |
||
| 893 | * @param string $p |
||
| 894 | */ |
||
| 895 | public function getEventLog(EventAttributeDecorator $event_decorator, ?string $id = null, ?string $p = null, ?array $attributes = [], int $offset = 0, int $limit = 20): Response |
||
| 910 | |||
| 911 | /** |
||
| 912 | * @api {get} /api/v2/nodes/last-cursor Get last Cursor |
||
| 913 | * @apiVersion 2.0.0 |
||
| 914 | * @apiName geLastCursor |
||
| 915 | * @apiGroup Node |
||
| 916 | * @apiUse _getNode |
||
| 917 | * @apiPermission none |
||
| 918 | * @apiDescription Use this method to request the latest cursor if you only need to now |
||
| 919 | * if there are changes on the server. This method will not return any other data than the |
||
| 920 | * newest cursor. To request a feed with all deltas request /delta. |
||
| 921 | * |
||
| 922 | * @apiExample (cURL) example: |
||
| 923 | * curl -XGET "https://SERVER/api/v2/nodes/last-cursor?pretty" |
||
| 924 | * |
||
| 925 | * @apiSuccess (200 OK) {string} cursor v2 cursor |
||
| 926 | * @apiSuccessExample {json} Success-Response: |
||
| 927 | * HTTP/1.1 200 OK |
||
| 928 | * "aW5pdGlhbHwxMDB8NTc1YTlhMGIzYzU4ODkwNTE0OGI0NTZifDU3NWE5YTBiM2M1ODg5MDUxNDhiNDU2Yw==" |
||
| 929 | * |
||
| 930 | * @param string $id |
||
| 931 | * @param string $p |
||
| 932 | */ |
||
| 933 | public function getLastCursor(?string $id = null, ?string $p = null): Response |
||
| 945 | |||
| 946 | /** |
||
| 947 | * Merge multiple nodes into one zip archive. |
||
| 948 | * |
||
| 949 | * @param string $id |
||
| 950 | * @param string $path |
||
| 951 | */ |
||
| 952 | protected function combine($id = null, $path = null, string $name = 'selected') |
||
| 969 | |||
| 970 | /** |
||
| 971 | * Check custom node attributes which have to be written. |
||
| 972 | */ |
||
| 973 | protected function _verifyAttributes(array $attributes): array |
||
| 1034 | } |
||
| 1035 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: