@@ -958,9 +958,9 @@ |
||
| 958 | 958 | $node->zip($archive); |
| 959 | 959 | } catch (\Exception $e) { |
| 960 | 960 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
| 961 | - 'category' => get_class($this), |
|
| 962 | - 'exception' => $e, |
|
| 963 | - ]); |
|
| 961 | + 'category' => get_class($this), |
|
| 962 | + 'exception' => $e, |
|
| 963 | + ]); |
|
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return $this->bulk($id, function ($node) use ($parent, $conflict, $move) { |
|
| 111 | + return $this->bulk($id, function($node) use ($parent, $conflict, $move) { |
|
| 112 | 112 | if (true === $move) { |
| 113 | 113 | $node = $node->setParent($parent, $conflict); |
| 114 | 114 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | return (new Response())->setCode(200)->setBody($result); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - return $this->bulk($id, function ($node) use ($attributes) { |
|
| 178 | + return $this->bulk($id, function($node) use ($attributes) { |
|
| 179 | 179 | return [ |
| 180 | 180 | 'code' => 200, |
| 181 | 181 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | public function patch(string $id, ?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, $lock = null): Response |
| 212 | 212 | { |
| 213 | 213 | $attributes = compact('name', 'meta', 'readonly', 'filter', 'lock'); |
| 214 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 214 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 215 | 215 | |
| 216 | 216 | $lock = $_SERVER['HTTP_LOCK_TOKEN'] ?? null; |
| 217 | 217 | |
| 218 | - return $this->bulk($id, function ($node) use ($attributes, $lock) { |
|
| 218 | + return $this->bulk($id, function($node) use ($attributes, $lock) { |
|
| 219 | 219 | foreach ($attributes as $attribute => $value) { |
| 220 | 220 | switch ($attribute) { |
| 221 | 221 | case 'name': |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | throw new Exception\NotFound('destination collection was not found or is not a collection', Exception\NotFound::DESTINATION_NOT_FOUND); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
| 271 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
| 272 | 272 | $result = $node->copyTo($parent, $conflict); |
| 273 | 273 | |
| 274 | 274 | return [ |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | throw new Exception\NotFound('destination collection was not found or is not a collection', Exception\NotFound::DESTINATION_NOT_FOUND); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
| 295 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
| 296 | 296 | $result = $node->setParent($parent, $conflict); |
| 297 | 297 | |
| 298 | 298 | return [ |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - return $this->bulk($id, function ($node) use ($force, $ignore_flag, $at) { |
|
| 320 | + return $this->bulk($id, function($node) use ($force, $ignore_flag, $at) { |
|
| 321 | 321 | if (null === $at) { |
| 322 | 322 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
| 323 | 323 | } else { |
@@ -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 | |
@@ -40,69 +40,69 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $response |
| 43 | - ->setOutputFormat(null) |
|
| 44 | - ->setBody(function () use ($file) { |
|
| 45 | - $stream = $file->get(); |
|
| 46 | - $name = $file->getName(); |
|
| 47 | - |
|
| 48 | - if (null === $stream) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $size = $file->getSize(); |
|
| 53 | - $length = $size; |
|
| 54 | - $start = 0; |
|
| 55 | - $end = $size - 1; |
|
| 56 | - |
|
| 57 | - set_time_limit(0); |
|
| 58 | - if (isset($_SERVER['HTTP_RANGE']) && strpos($_SERVER['HTTP_RANGE'], '=') !== false) { |
|
| 59 | - header('Accept-Ranges: bytes'); |
|
| 60 | - $c_start = $start; |
|
| 61 | - $c_end = $end; |
|
| 62 | - list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 63 | - |
|
| 64 | - if (strpos($range, ',') !== false) { |
|
| 65 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 66 | - |
|
| 67 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if ($range == '-') { |
|
| 71 | - $c_start = $size - substr($range, 1); |
|
| 72 | - } else { |
|
| 73 | - $range = explode('-', $range); |
|
| 74 | - $c_start = $range[0]; |
|
| 75 | - $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 79 | - if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 80 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 81 | - |
|
| 82 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $start = (int) $c_start; |
|
| 86 | - $end = (int) $c_end; |
|
| 87 | - $length = (int) $end - $start + 1; |
|
| 88 | - fseek($stream, $start); |
|
| 89 | - header('HTTP/1.1 206 Partial Content'); |
|
| 90 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - header('Content-Length: '.$length); |
|
| 94 | - $buffer = 1024 * 8; |
|
| 95 | - |
|
| 96 | - while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 97 | - if ($p + $buffer > $end) { |
|
| 98 | - $buffer = $end - $p + 1; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - echo fread($stream, $buffer); |
|
| 102 | - flush(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - fclose($stream); |
|
| 106 | - }); |
|
| 43 | + ->setOutputFormat(null) |
|
| 44 | + ->setBody(function () use ($file) { |
|
| 45 | + $stream = $file->get(); |
|
| 46 | + $name = $file->getName(); |
|
| 47 | + |
|
| 48 | + if (null === $stream) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $size = $file->getSize(); |
|
| 53 | + $length = $size; |
|
| 54 | + $start = 0; |
|
| 55 | + $end = $size - 1; |
|
| 56 | + |
|
| 57 | + set_time_limit(0); |
|
| 58 | + if (isset($_SERVER['HTTP_RANGE']) && strpos($_SERVER['HTTP_RANGE'], '=') !== false) { |
|
| 59 | + header('Accept-Ranges: bytes'); |
|
| 60 | + $c_start = $start; |
|
| 61 | + $c_end = $end; |
|
| 62 | + list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 63 | + |
|
| 64 | + if (strpos($range, ',') !== false) { |
|
| 65 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 66 | + |
|
| 67 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if ($range == '-') { |
|
| 71 | + $c_start = $size - substr($range, 1); |
|
| 72 | + } else { |
|
| 73 | + $range = explode('-', $range); |
|
| 74 | + $c_start = $range[0]; |
|
| 75 | + $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 79 | + if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 80 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 81 | + |
|
| 82 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $start = (int) $c_start; |
|
| 86 | + $end = (int) $c_end; |
|
| 87 | + $length = (int) $end - $start + 1; |
|
| 88 | + fseek($stream, $start); |
|
| 89 | + header('HTTP/1.1 206 Partial Content'); |
|
| 90 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + header('Content-Length: '.$length); |
|
| 94 | + $buffer = 1024 * 8; |
|
| 95 | + |
|
| 96 | + while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 97 | + if ($p + $buffer > $end) { |
|
| 98 | + $buffer = $end - $p + 1; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + echo fread($stream, $buffer); |
|
| 102 | + flush(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + fclose($stream); |
|
| 106 | + }); |
|
| 107 | 107 | } |
| 108 | 108 | } |
@@ -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 | } |
@@ -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 | } |
@@ -590,6 +590,7 @@ |
||
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | 592 | * Create new file as a child from this collection. |
| 593 | + * @param string $name |
|
| 593 | 594 | */ |
| 594 | 595 | public function addFile($name, ?SessionInterface $session = null, array $attributes = [], int $conflict = NodeInterface::CONFLICT_NOACTION, bool $clone = false): File |
| 595 | 596 | { |
@@ -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 Balloon\Session\Factory as SessionFactory; |
| 22 | 21 | use Balloon\Session\SessionInterface; |
| 23 | 22 | use Generator; |
@@ -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, |
@@ -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 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $attributes = compact('password', 'soft_quota', 'hard_quota', 'avatar', 'mail', 'admin', 'namespace', 'locale'); |
| 164 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 164 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 165 | 165 | |
| 166 | 166 | if (isset($attributes['avatar'])) { |
| 167 | 167 | $attributes['avatar'] = new Binary(base64_decode($attributes['avatar']), Binary::TYPE_GENERIC); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | public function patch(string $id, ?string $username = null, ?string $password = null, ?int $soft_quota = null, ?int $hard_quota = null, ?string $avatar = null, ?string $mail = null, ?bool $admin = null, ?string $namespace = null, ?string $locale = null, ?bool $multi_factor_auth = null): Response |
| 180 | 180 | { |
| 181 | 181 | $attributes = compact('username', 'password', 'soft_quota', 'hard_quota', 'avatar', 'mail', 'admin', 'namespace', 'locale', 'multi_factor_auth'); |
| 182 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 182 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 183 | 183 | |
| 184 | 184 | if (isset($attributes['avatar'])) { |
| 185 | 185 | $attributes['avatar'] = new Binary(base64_decode($attributes['avatar']), Binary::TYPE_GENERIC); |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * @param string $class Force set node type |
| 74 | 74 | * @param bool $multiple Allow $id to be an array |
| 75 | 75 | * @param bool $allow_root Allow instance of root collection |
| 76 | - * @param bool $deleted How to handle deleted node |
|
| 76 | + * @param integer $deleted How to handle deleted node |
|
| 77 | 77 | */ |
| 78 | 78 | protected function _getNode( |
| 79 | 79 | ?string $id = null, |
@@ -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, ?string $name = null, ?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); |