@@ -273,37 +273,37 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | return $response |
276 | - ->setOutputFormat(null) |
|
277 | - ->setBody(function () use ($node, $offset, $limit) { |
|
278 | - $stream = $node->get(); |
|
279 | - $name = $node->getName(); |
|
280 | - |
|
281 | - if (null === $stream) { |
|
282 | - return; |
|
283 | - } |
|
284 | - |
|
285 | - if (0 !== $offset) { |
|
286 | - if (fseek($stream, $offset) === -1) { |
|
287 | - throw new Exception\Conflict( |
|
276 | + ->setOutputFormat(null) |
|
277 | + ->setBody(function () use ($node, $offset, $limit) { |
|
278 | + $stream = $node->get(); |
|
279 | + $name = $node->getName(); |
|
280 | + |
|
281 | + if (null === $stream) { |
|
282 | + return; |
|
283 | + } |
|
284 | + |
|
285 | + if (0 !== $offset) { |
|
286 | + if (fseek($stream, $offset) === -1) { |
|
287 | + throw new Exception\Conflict( |
|
288 | 288 | 'invalid offset requested', |
289 | 289 | Exception\Conflict::INVALID_OFFSET |
290 | 290 | ); |
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - $read = 0; |
|
295 | - while (!feof($stream)) { |
|
296 | - if (0 !== $limit && $read + 8192 > $limit) { |
|
297 | - echo fread($stream, $limit - $read); |
|
298 | - exit(); |
|
299 | - } |
|
300 | - |
|
301 | - echo fread($stream, 8192); |
|
302 | - $read += 8192; |
|
303 | - } |
|
304 | - |
|
305 | - exit(); |
|
306 | - }); |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + $read = 0; |
|
295 | + while (!feof($stream)) { |
|
296 | + if (0 !== $limit && $read + 8192 > $limit) { |
|
297 | + echo fread($stream, $limit - $read); |
|
298 | + exit(); |
|
299 | + } |
|
300 | + |
|
301 | + echo fread($stream, 8192); |
|
302 | + $read += 8192; |
|
303 | + } |
|
304 | + |
|
305 | + exit(); |
|
306 | + }); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -1053,9 +1053,9 @@ discard block |
||
1053 | 1053 | $node->zip($archive); |
1054 | 1054 | } catch (\Exception $e) { |
1055 | 1055 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
1056 | - 'category' => get_class($this), |
|
1057 | - 'exception' => $e, |
|
1058 | - ]); |
|
1056 | + 'category' => get_class($this), |
|
1057 | + 'exception' => $e, |
|
1058 | + ]); |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict, $move) { |
|
190 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict, $move) { |
|
191 | 191 | if (true === $move) { |
192 | 192 | $node = $node->setParent($parent, $conflict); |
193 | 193 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | return $response |
276 | 276 | ->setOutputFormat(null) |
277 | - ->setBody(function () use ($node, $offset, $limit) { |
|
277 | + ->setBody(function() use ($node, $offset, $limit) { |
|
278 | 278 | $stream = $node->get(); |
279 | 279 | $name = $node->getName(); |
280 | 280 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | return (new Response())->setCode(200)->setBody($result); |
411 | 411 | } |
412 | 412 | |
413 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
413 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
414 | 414 | return [ |
415 | 415 | 'code' => 200, |
416 | 416 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | public function patch(?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, ?string $id = null, ?string $p = null): Response |
525 | 525 | { |
526 | 526 | $attributes = compact('name', 'meta', 'readonly', 'filter'); |
527 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
527 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
528 | 528 | |
529 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
529 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
530 | 530 | foreach ($attributes as $attribute => $value) { |
531 | 531 | switch ($attribute) { |
532 | 532 | case 'name': |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | ); |
609 | 609 | } |
610 | 610 | |
611 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
611 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
612 | 612 | $result = $node->copyTo($parent, $conflict); |
613 | 613 | |
614 | 614 | return [ |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | ); |
673 | 673 | } |
674 | 674 | |
675 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
675 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
676 | 676 | $result = $node->setParent($parent, $conflict); |
677 | 677 | |
678 | 678 | return [ |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
727 | 727 | } |
728 | 728 | |
729 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
729 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
730 | 730 | if (null === $at) { |
731 | 731 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
732 | 732 | } else { |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $class Force set node type |
211 | 211 | * @param bool $multiple Allow $id to be an array |
212 | 212 | * @param bool $allow_root Allow instance of root collection |
213 | - * @param bool $deleted How to handle deleted node |
|
213 | + * @param integer $deleted How to handle deleted node |
|
214 | 214 | */ |
215 | 215 | protected function _getNode( |
216 | 216 | ?string $id = null, |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param string $id |
243 | 243 | * @param string $path |
244 | 244 | * @param string $class Force set node type |
245 | - * @param bool $deleted How to handle deleted node |
|
245 | + * @param integer $deleted How to handle deleted node |
|
246 | 246 | */ |
247 | 247 | protected function _getNodes( |
248 | 248 | $id = null, |
@@ -86,7 +86,7 @@ |
||
86 | 86 | * Add decorator. |
87 | 87 | * |
88 | 88 | * |
89 | - * @return AttributeDecorator |
|
89 | + * @return NodeDecorator |
|
90 | 90 | */ |
91 | 91 | public function addDecorator(string $attribute, Closure $decorator): self |
92 | 92 | { |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | 'mime' => (string) $attributes['mime'], |
128 | 128 | 'readonly' => (bool) $attributes['readonly'], |
129 | 129 | 'directory' => $node instanceof Collection, |
130 | - 'meta' => function ($node) { |
|
130 | + 'meta' => function($node) { |
|
131 | 131 | return (object) $node->getMetaAttributes(); |
132 | 132 | }, |
133 | - 'size' => function ($node) { |
|
133 | + 'size' => function($node) { |
|
134 | 134 | return $node->getSize(); |
135 | 135 | }, |
136 | - 'path' => function ($node) { |
|
136 | + 'path' => function($node) { |
|
137 | 137 | try { |
138 | 138 | return $node->getPath(); |
139 | 139 | } catch (\Exception $e) { |
140 | 140 | return null; |
141 | 141 | } |
142 | 142 | }, |
143 | - 'parent' => function ($node) { |
|
143 | + 'parent' => function($node) { |
|
144 | 144 | $id = $node->getAttributes()['parent']; |
145 | 145 | |
146 | 146 | if (null === $id) { |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | |
150 | 150 | return (string) $id; |
151 | 151 | }, |
152 | - 'access' => function ($node) use ($acl) { |
|
152 | + 'access' => function($node) use ($acl) { |
|
153 | 153 | return $acl->getAclPrivilege($node); |
154 | 154 | }, |
155 | - 'share' => function ($node) { |
|
155 | + 'share' => function($node) { |
|
156 | 156 | if (!$node->isShared() && !$node->isSpecial()) { |
157 | 157 | return false; |
158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | }, |
166 | - 'shareowner' => function ($node) use ($server, $fs) { |
|
166 | + 'shareowner' => function($node) use ($server, $fs) { |
|
167 | 167 | if (!$node->isSpecial()) { |
168 | 168 | return null; |
169 | 169 | } |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
207 | 207 | { |
208 | 208 | return [ |
209 | - 'created' => function ($node) use ($attributes) { |
|
209 | + 'created' => function($node) use ($attributes) { |
|
210 | 210 | return $this->dateTimeToUnix($attributes['created']); |
211 | 211 | }, |
212 | - 'changed' => function ($node) use ($attributes) { |
|
212 | + 'changed' => function($node) use ($attributes) { |
|
213 | 213 | return $this->dateTimeToUnix($attributes['changed']); |
214 | 214 | }, |
215 | - 'deleted' => function ($node) use ($attributes) { |
|
215 | + 'deleted' => function($node) use ($attributes) { |
|
216 | 216 | if (false === $attributes['deleted']) { |
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | 220 | return $this->dateTimeToUnix($attributes['deleted']); |
221 | 221 | }, |
222 | - 'destroy' => function ($node) use ($attributes) { |
|
222 | + 'destroy' => function($node) use ($attributes) { |
|
223 | 223 | if (null === $attributes['destroy']) { |
224 | 224 | return null; |
225 | 225 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | * |
116 | 116 | * @param string $id |
117 | 117 | * @param string $p |
118 | - * @param string $version |
|
118 | + * @param integer $version |
|
119 | 119 | */ |
120 | 120 | public function postRestore(int $version, ?string $id = null, ?string $p = null): Response |
121 | 121 | { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | * |
49 | - * @param Notification $notifier |
|
49 | + * @param Notifier $notifier |
|
50 | 50 | */ |
51 | 51 | public function __construct(Notifier $notifier, Server $server, LoggerInterface $logger) |
52 | 52 | { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * Check if users needs a notification and checks if mail adress is available. |
107 | 107 | * |
108 | 108 | * |
109 | - * @return string |
|
109 | + * @return boolean |
|
110 | 110 | */ |
111 | 111 | protected function checkNotify(NodeInterface $node, User $user): bool |
112 | 112 | { |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace Balloon\App\Notification\Hook; |
13 | 13 | |
14 | 14 | use Balloon\App\Notification\Notifier; |
15 | -use Balloon\Async\Mail; |
|
16 | 15 | use Balloon\Filesystem\Node\Collection; |
17 | 16 | use Balloon\Filesystem\Node\NodeInterface; |
18 | 17 | use Balloon\Hook\AbstractHook; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * Load nodes by id. |
282 | 282 | * |
283 | 283 | * @param string $class Force check node type |
284 | - * @param bool $deleted |
|
284 | + * @param integer $deleted |
|
285 | 285 | */ |
286 | 286 | public function findNodesById(array $id = [], ?string $class = null, int $deleted = NodeInterface::DELETED_INCLUDE): Generator |
287 | 287 | { |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @param string $class Force set node type |
403 | 403 | * @param bool $multiple Allow $id to be an array |
404 | 404 | * @param bool $allow_root Allow instance of root collection |
405 | - * @param bool $deleted How to handle deleted node |
|
405 | + * @param integer $deleted How to handle deleted node |
|
406 | 406 | */ |
407 | 407 | public function getNode($id = null, $path = null, $class = null, bool $multiple = false, bool $allow_root = false, int $deleted = NodeInterface::DELETED_EXCLUDE): NodeInterface |
408 | 408 | { |
@@ -344,6 +344,7 @@ |
||
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Get delta feed filter. |
347 | + * @param NodeInterface|null $node |
|
347 | 348 | */ |
348 | 349 | protected function buildDeltaFeedFilter(array $cursor, int $limit, ?NodeInterface $node): array |
349 | 350 | { |
@@ -195,6 +195,7 @@ |
||
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Filesystem factory. |
198 | + * @param User $user |
|
198 | 199 | */ |
199 | 200 | public function getFilesystem(?User $user = null): Filesystem |
200 | 201 | { |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | |
534 | 534 | $this->identity = $user; |
535 | 535 | $user->updateIdentity($identity) |
536 | - ->updateShares(); |
|
536 | + ->updateShares(); |
|
537 | 537 | $this->hook->run('postServerIdentity', [$user]); |
538 | 538 | |
539 | 539 | return true; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | public function getGroupByName(string $name): Group |
643 | 643 | { |
644 | 644 | $group = $this->db->group->findOne([ |
645 | - 'name' => $name, |
|
645 | + 'name' => $name, |
|
646 | 646 | ]); |
647 | 647 | |
648 | 648 | if (null === $group) { |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | $group = $this->db->group->findOne([ |
667 | - '_id' => $id, |
|
667 | + '_id' => $id, |
|
668 | 668 | ]); |
669 | 669 | |
670 | 670 | if (null === $group) { |
@@ -101,7 +101,7 @@ |
||
101 | 101 | break; |
102 | 102 | default: |
103 | 103 | throw new InvalidArgumentException('invalid option '.$option.' given'); |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $this; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function decorate(string $template, array $context): string |
221 | 221 | { |
222 | - return preg_replace_callback('/\{([^}\.]*)\}/', function ($match) use ($context) { |
|
222 | + return preg_replace_callback('/\{([^}\.]*)\}/', function($match) use ($context) { |
|
223 | 223 | $key = $match[1]; |
224 | 224 | |
225 | 225 | if (isset($context[$key])) { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | { |
236 | 236 | $decorator = $this->decorator; |
237 | 237 | |
238 | - return preg_replace_callback('/(\{node\.(([a-z]\.*)+)\})/', function ($match) use ($node, $decorator) { |
|
238 | + return preg_replace_callback('/(\{node\.(([a-z]\.*)+)\})/', function($match) use ($node, $decorator) { |
|
239 | 239 | $key = explode('.', $match[2]); |
240 | 240 | $key = array_shift($key); |
241 | 241 | $attrs = $decorator->decorate($node, [$key]); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | { |
252 | 252 | $role_decorator = $this->role_decorator; |
253 | 253 | |
254 | - return preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function ($match) use ($user, $role_decorator) { |
|
254 | + return preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function($match) use ($user, $role_decorator) { |
|
255 | 255 | $key = explode('.', $match[2]); |
256 | 256 | $key = array_shift($key); |
257 | 257 | $attrs = $role_decorator->decorate($user, [$key]); |