@@ -246,7 +246,7 @@ |
||
246 | 246 | $delta[$share_member->getPath()] = $share_member; |
247 | 247 | } |
248 | 248 | } elseif ('undeleteCollection' === $log['operation'] || 'undeleteCollectionShare' === $log['operation']) { |
249 | - $log_node->doRecursiveAction(function ($sub_node) use (&$delta) { |
|
249 | + $log_node->doRecursiveAction(function($sub_node) use (&$delta) { |
|
250 | 250 | $delta[$sub_node->getPath()] = $sub_node; |
251 | 251 | }); |
252 | 252 | } |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Build a single dimension array with all nodes. |
101 | + * @param integer[] $cursor |
|
101 | 102 | */ |
102 | 103 | public function buildFeedFromCurrentState(?array $cursor = null, int $limit = 100, ?NodeInterface $node = null): array |
103 | 104 | { |
@@ -220,6 +221,7 @@ discard block |
||
220 | 221 | |
221 | 222 | /** |
222 | 223 | * Get delta feed with changes and cursor. |
224 | + * @param NodeInterface $node |
|
223 | 225 | */ |
224 | 226 | public function getDeltaFeed(?string $cursor = null, int $limit = 250, ?NodeInterface $node = null): array |
225 | 227 | { |
@@ -327,6 +329,7 @@ discard block |
||
327 | 329 | |
328 | 330 | /** |
329 | 331 | * Get event log. |
332 | + * @param NodeInterface $node |
|
330 | 333 | */ |
331 | 334 | public function getEventLog(int $limit = 100, int $skip = 0, ?NodeInterface $node = null, ?int &$total = null): Iterable |
332 | 335 | { |
@@ -575,6 +578,7 @@ discard block |
||
575 | 578 | |
576 | 579 | /** |
577 | 580 | * Get children with custom filter. |
581 | + * @param integer $limit |
|
578 | 582 | */ |
579 | 583 | protected function findNodeAttributesWithCustomFilter( |
580 | 584 | ?array $filter = null, |
@@ -34,68 +34,68 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | return $response |
37 | - ->setOutputFormat(null) |
|
38 | - ->setBody(function () use ($file) { |
|
39 | - $stream = $file->get(); |
|
40 | - $name = $file->getName(); |
|
41 | - |
|
42 | - if (null === $stream) { |
|
43 | - return; |
|
44 | - } |
|
45 | - |
|
46 | - $size = $file->getSize(); |
|
47 | - $length = $size; |
|
48 | - $start = 0; |
|
49 | - $end = $size - 1; |
|
50 | - |
|
51 | - if (isset($_SERVER['HTTP_RANGE'])) { |
|
52 | - header('Accept-Ranges: bytes'); |
|
53 | - $c_start = $start; |
|
54 | - $c_end = $end; |
|
55 | - list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
56 | - |
|
57 | - if (strpos($range, ',') !== false) { |
|
58 | - header("Content-Range: bytes $start-$end/$size"); |
|
59 | - |
|
60 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
61 | - } |
|
62 | - |
|
63 | - if ($range == '-') { |
|
64 | - $c_start = $size - substr($range, 1); |
|
65 | - } else { |
|
66 | - $range = explode('-', $range); |
|
67 | - $c_start = $range[0]; |
|
68 | - $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
69 | - } |
|
70 | - |
|
71 | - $c_end = ($c_end > $end) ? $end : $c_end; |
|
72 | - if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
73 | - header("Content-Range: bytes $start-$end/$size"); |
|
74 | - |
|
75 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
76 | - } |
|
77 | - |
|
78 | - $start = (int) $c_start; |
|
79 | - $end = (int) $c_end; |
|
80 | - $length = (int) $end - $start + 1; |
|
81 | - fseek($stream, $start); |
|
82 | - header('HTTP/1.1 206 Partial Content'); |
|
83 | - header("Content-Range: bytes $start-$end/$size"); |
|
84 | - } |
|
85 | - |
|
86 | - header('Content-Length: '.$length); |
|
87 | - $buffer = 1024 * 8; |
|
88 | - |
|
89 | - while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
90 | - if ($p + $buffer > $end) { |
|
91 | - $buffer = $end - $p + 1; |
|
92 | - } |
|
93 | - |
|
94 | - echo fread($stream, $buffer); |
|
95 | - flush(); |
|
96 | - } |
|
97 | - |
|
98 | - fclose($stream); |
|
99 | - }); |
|
37 | + ->setOutputFormat(null) |
|
38 | + ->setBody(function () use ($file) { |
|
39 | + $stream = $file->get(); |
|
40 | + $name = $file->getName(); |
|
41 | + |
|
42 | + if (null === $stream) { |
|
43 | + return; |
|
44 | + } |
|
45 | + |
|
46 | + $size = $file->getSize(); |
|
47 | + $length = $size; |
|
48 | + $start = 0; |
|
49 | + $end = $size - 1; |
|
50 | + |
|
51 | + if (isset($_SERVER['HTTP_RANGE'])) { |
|
52 | + header('Accept-Ranges: bytes'); |
|
53 | + $c_start = $start; |
|
54 | + $c_end = $end; |
|
55 | + list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
56 | + |
|
57 | + if (strpos($range, ',') !== false) { |
|
58 | + header("Content-Range: bytes $start-$end/$size"); |
|
59 | + |
|
60 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
61 | + } |
|
62 | + |
|
63 | + if ($range == '-') { |
|
64 | + $c_start = $size - substr($range, 1); |
|
65 | + } else { |
|
66 | + $range = explode('-', $range); |
|
67 | + $c_start = $range[0]; |
|
68 | + $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
69 | + } |
|
70 | + |
|
71 | + $c_end = ($c_end > $end) ? $end : $c_end; |
|
72 | + if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
73 | + header("Content-Range: bytes $start-$end/$size"); |
|
74 | + |
|
75 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
76 | + } |
|
77 | + |
|
78 | + $start = (int) $c_start; |
|
79 | + $end = (int) $c_end; |
|
80 | + $length = (int) $end - $start + 1; |
|
81 | + fseek($stream, $start); |
|
82 | + header('HTTP/1.1 206 Partial Content'); |
|
83 | + header("Content-Range: bytes $start-$end/$size"); |
|
84 | + } |
|
85 | + |
|
86 | + header('Content-Length: '.$length); |
|
87 | + $buffer = 1024 * 8; |
|
88 | + |
|
89 | + while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
90 | + if ($p + $buffer > $end) { |
|
91 | + $buffer = $end - $p + 1; |
|
92 | + } |
|
93 | + |
|
94 | + echo fread($stream, $buffer); |
|
95 | + flush(); |
|
96 | + } |
|
97 | + |
|
98 | + fclose($stream); |
|
99 | + }); |
|
100 | 100 | } |
101 | 101 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | return $response |
37 | 37 | ->setOutputFormat(null) |
38 | - ->setBody(function () use ($file) { |
|
38 | + ->setBody(function() use ($file) { |
|
39 | 39 | $stream = $file->get(); |
40 | 40 | $name = $file->getName(); |
41 | 41 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $this->db->storage->updateOne( |
50 | 50 | ['_id' => $object['_id']], |
51 | 51 | [ |
52 | - '$set' => ['pointer' => $pointer], |
|
52 | + '$set' => ['pointer' => $pointer], |
|
53 | 53 | ] |
54 | 54 | ); |
55 | 55 | } |
@@ -656,6 +656,7 @@ |
||
656 | 656 | |
657 | 657 | /** |
658 | 658 | * Create new file as a child from this collection. |
659 | + * @param string $name |
|
659 | 660 | */ |
660 | 661 | public function addFile($name, ?ObjectId $session = null, array $attributes = [], int $conflict = NodeInterface::CONFLICT_NOACTION, bool $clone = false): File |
661 | 662 | { |
@@ -17,7 +17,6 @@ |
||
17 | 17 | use Balloon\Filesystem\Exception; |
18 | 18 | use Balloon\Filesystem\Storage\Adapter\AdapterInterface as StorageAdapterInterface; |
19 | 19 | use Balloon\Hook; |
20 | -use Balloon\Server\User; |
|
21 | 20 | use Generator; |
22 | 21 | use MimeType\MimeType; |
23 | 22 | use function MongoDB\BSON\fromJSON; |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $this->storage = $this->_parent->getStorage()->deleteCollection($this); |
363 | 363 | |
364 | 364 | if (!$this->isReference() && !$this->isMounted() && !$this->isFiltered()) { |
365 | - $this->doRecursiveAction(function ($node) use ($recursion) { |
|
365 | + $this->doRecursiveAction(function($node) use ($recursion) { |
|
366 | 366 | $node->delete(false, $recursion, false); |
367 | 367 | }, NodeInterface::DELETED_EXCLUDE); |
368 | 368 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | protected function _forceDelete(?string $recursion = null, bool $recursion_first = true): bool |
918 | 918 | { |
919 | 919 | if (!$this->isReference() && !$this->isMounted() && !$this->isFiltered()) { |
920 | - $this->doRecursiveAction(function ($node) use ($recursion) { |
|
920 | + $this->doRecursiveAction(function($node) use ($recursion) { |
|
921 | 921 | $node->delete(true, $recursion, false); |
922 | 922 | }, NodeInterface::DELETED_INCLUDE); |
923 | 923 | } |
@@ -970,9 +970,9 @@ |
||
970 | 970 | //json_decode($stored, true), |
971 | 971 | } catch (\Exception $e) { |
972 | 972 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
973 | - 'category' => get_class($this), |
|
974 | - 'exception' => $e, |
|
975 | - ]); |
|
973 | + 'category' => get_class($this), |
|
974 | + 'exception' => $e, |
|
975 | + ]); |
|
976 | 976 | } |
977 | 977 | } |
978 | 978 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - return $this->bulk($id, function ($node) use ($parent, $conflict, $move) { |
|
105 | + return $this->bulk($id, function($node) use ($parent, $conflict, $move) { |
|
106 | 106 | if (true === $move) { |
107 | 107 | $node = $node->setParent($parent, $conflict); |
108 | 108 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | return (new Response())->setCode(200)->setBody($result); |
177 | 177 | } |
178 | 178 | |
179 | - return $this->bulk($id, function ($node) use ($attributes) { |
|
179 | + return $this->bulk($id, function($node) use ($attributes) { |
|
180 | 180 | return [ |
181 | 181 | 'code' => 200, |
182 | 182 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | public function patch(string $id, ?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, ?array $acl = null): Response |
211 | 211 | { |
212 | 212 | $attributes = compact('name', 'meta', 'readonly', 'filter', 'acl'); |
213 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
213 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
214 | 214 | |
215 | - return $this->bulk($id, function ($node) use ($attributes) { |
|
215 | + return $this->bulk($id, function($node) use ($attributes) { |
|
216 | 216 | foreach ($attributes as $attribute => $value) { |
217 | 217 | switch ($attribute) { |
218 | 218 | case 'name': |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ); |
265 | 265 | } |
266 | 266 | |
267 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
267 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
268 | 268 | $result = $node->copyTo($parent, $conflict); |
269 | 269 | |
270 | 270 | return [ |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ); |
292 | 292 | } |
293 | 293 | |
294 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
294 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
295 | 295 | $result = $node->setParent($parent, $conflict); |
296 | 296 | |
297 | 297 | return [ |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
317 | 317 | } |
318 | 318 | |
319 | - return $this->bulk($id, function ($node) use ($force, $ignore_flag, $at) { |
|
319 | + return $this->bulk($id, function($node) use ($force, $ignore_flag, $at) { |
|
320 | 320 | if (null === $at) { |
321 | 321 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
322 | 322 | } else { |
@@ -249,6 +249,8 @@ discard block |
||
249 | 249 | * Load nodes by id. |
250 | 250 | * |
251 | 251 | * @param null|mixed $class |
252 | + * @param string $id |
|
253 | + * @param string $path |
|
252 | 254 | */ |
253 | 255 | public function getNodes(?array $id = null, ?array $path = null, $class = null, int $deleted = NodeInterface::DELETED_EXCLUDE): Generator |
254 | 256 | { |
@@ -277,9 +279,10 @@ discard block |
||
277 | 279 | /** |
278 | 280 | * Load node. |
279 | 281 | * |
280 | - * @param null|mixed $id |
|
281 | - * @param null|mixed $path |
|
282 | + * @param string|null $id |
|
283 | + * @param string|null $path |
|
282 | 284 | * @param null|mixed $class |
285 | + * @param integer $deleted |
|
283 | 286 | */ |
284 | 287 | public function getNode($id = null, $path = null, $class = null, bool $multiple = false, bool $allow_root = false, ?int $deleted = null): NodeInterface |
285 | 288 | { |
@@ -359,7 +362,7 @@ discard block |
||
359 | 362 | * @param string $class Force set node type |
360 | 363 | * @param bool $multiple Allow $id to be an array |
361 | 364 | * @param bool $allow_root Allow instance of root collection |
362 | - * @param bool $deleted How to handle deleted node |
|
365 | + * @param integer $deleted How to handle deleted node |
|
363 | 366 | */ |
364 | 367 | protected function _getNode( |
365 | 368 | ?string $id = null, |
@@ -391,7 +394,7 @@ discard block |
||
391 | 394 | * @param string $id |
392 | 395 | * @param string $path |
393 | 396 | * @param string $class Force set node type |
394 | - * @param bool $deleted How to handle deleted node |
|
397 | + * @param integer $deleted How to handle deleted node |
|
395 | 398 | */ |
396 | 399 | protected function _getNodes( |
397 | 400 | $id = null, |
@@ -477,6 +477,8 @@ |
||
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Get custom filtered children. |
480 | + * @param integer $offset |
|
481 | + * @param integer $limit |
|
480 | 482 | */ |
481 | 483 | public function findNodesByFilterUser(int $deleted, array $filter, ?int $offset = null, ?int $limit = null): Generator |
482 | 484 | { |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $params = $response->getParameters(); |
44 | 44 | |
45 | 45 | return (new Response()) |
46 | - ->setCode($response->getStatusCode()) |
|
47 | - ->setBody($params); |
|
46 | + ->setCode($response->getStatusCode()) |
|
47 | + ->setBody($params); |
|
48 | 48 | } |
49 | 49 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $attributes = compact('namespace'); |
124 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
124 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
125 | 125 | |
126 | 126 | $id = $this->server->addGroup($name, $member, $attributes); |
127 | 127 | $result = $this->decorator->decorate($this->server->getGroupById($id)); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | public function patch(string $id, ?array $member = null, ?string $namespace = null): Response |
136 | 136 | { |
137 | 137 | $attributes = compact('namespace', 'name', 'member'); |
138 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
138 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
139 | 139 | |
140 | 140 | $group = $this->_getGroup($id, true); |
141 | 141 | $group->setAttributes($attributes); |