@@ -82,7 +82,7 @@ |
||
82 | 82 | $node_decorator = $this->node_decorator; |
83 | 83 | $notifier = $this->notifier; |
84 | 84 | |
85 | - return $this->bulk($id, $p, function ($node) use ($node_decorator, $notifier, $subscribe, $exclude_me, $recursive) { |
|
85 | + return $this->bulk($id, $p, function($node) use ($node_decorator, $notifier, $subscribe, $exclude_me, $recursive) { |
|
86 | 86 | $notifier->subscribeNode($node, $subscribe, $exclude_me, $recursive); |
87 | 87 | |
88 | 88 | return [ |
@@ -102,7 +102,7 @@ |
||
102 | 102 | 'id' => (string) $message['_id'], |
103 | 103 | 'message' => (string) $message['body'], |
104 | 104 | 'subject' => (string) $message['subject'], |
105 | - 'sender' => function ($message) use ($server, $role_decorator) { |
|
105 | + 'sender' => function($message) use ($server, $role_decorator) { |
|
106 | 106 | if (!isset($message['sender'])) { |
107 | 107 | return null; |
108 | 108 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | ->setHeader('Content-Type', 'application/octet-stream') |
65 | 65 | ->setHeader('Content-Transfer-Encoding', 'binary') |
66 | 66 | ->setOutputFormat(null) |
67 | - ->setBody(function () use ($url) { |
|
67 | + ->setBody(function() use ($url) { |
|
68 | 68 | $stream = fopen($url, 'r'); |
69 | 69 | while (!feof($stream)) { |
70 | 70 | echo fread($stream, 8192); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | ->prependRoute(new Route('/api/v2/files/convert(/|\z)', Convert::class)) |
35 | 35 | ->prependRoute(new Route('/api/v2/files/{id:#([0-9a-z]{24})#}/convert(/|\z)', Convert::class)); |
36 | 36 | |
37 | - $node_decorator->addDecorator('master', function ($node) use ($convert_decorator, $converter) { |
|
37 | + $node_decorator->addDecorator('master', function($node) use ($convert_decorator, $converter) { |
|
38 | 38 | $master = $node->getAppAttribute('Balloon\\App\\Convert', 'master'); |
39 | 39 | if (null === $master) { |
40 | 40 | return null; |
@@ -101,14 +101,14 @@ |
||
101 | 101 | return [ |
102 | 102 | 'id' => (string) $slave['_id'], |
103 | 103 | 'format' => (string) $slave['format'], |
104 | - 'master' => function ($slave) use ($fs, $node_decorator) { |
|
104 | + 'master' => function($slave) use ($fs, $node_decorator) { |
|
105 | 105 | try { |
106 | 106 | return $node_decorator->decorate($fs->findNodeById($slave['master']), ['_links', 'id', 'name']); |
107 | 107 | } catch (\Exception $e) { |
108 | 108 | return null; |
109 | 109 | } |
110 | 110 | }, |
111 | - 'slave' => function ($slave) use ($fs, $node_decorator) { |
|
111 | + 'slave' => function($slave) use ($fs, $node_decorator) { |
|
112 | 112 | if (!isset($slave['slave'])) { |
113 | 113 | return null; |
114 | 114 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct(AttributeDecorator $decorator) |
26 | 26 | { |
27 | - $decorator->addDecorator('malware_quarantine', function ($node) { |
|
27 | + $decorator->addDecorator('malware_quarantine', function($node) { |
|
28 | 28 | if ($node instanceof File) { |
29 | 29 | $quarantine = $node->getAppAttribute('Balloon\\App\\ClamAv', 'quarantine'); |
30 | 30 | if (is_bool($quarantine)) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | }); |
35 | - $decorator->addDecorator('malware_scantime', function ($node) { |
|
35 | + $decorator->addDecorator('malware_scantime', function($node) { |
|
36 | 36 | if ($node instanceof File) { |
37 | 37 | $ts = $node->getAppAttribute('Balloon\\App\\ClamAv', 'scantime'); |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | }); |
44 | - $decorator->addDecorator('malware_reason', function ($node) { |
|
44 | + $decorator->addDecorator('malware_reason', function($node) { |
|
45 | 45 | if ($node instanceof File) { |
46 | 46 | return $node->getAppAttribute('Balloon\\App\\ClamAv', 'reason'); |
47 | 47 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | $attributes = compact('namespace', 'optional'); |
273 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
273 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
274 | 274 | |
275 | 275 | $id = $this->server->addGroup($name, $member, $attributes); |
276 | 276 | $result = $this->decorator->decorate($this->server->getGroupById($id)); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | public function patch(string $id, ?array $member = null, ?string $namespace = null, ?array $optional = null): Response |
310 | 310 | { |
311 | 311 | $attributes = compact('namespace', 'optional', 'name', 'member'); |
312 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
312 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
313 | 313 | |
314 | 314 | $group = $this->_getGroup($id, true); |
315 | 315 | $group->setAttributes($attributes); |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | return [ |
108 | - 'created' => function ($role, $requested) use ($attributes) { |
|
108 | + 'created' => function($role, $requested) use ($attributes) { |
|
109 | 109 | return $attributes['created']->toDateTime()->format('c'); |
110 | 110 | }, |
111 | - 'changed' => function ($role, $requested) use ($attributes) { |
|
111 | + 'changed' => function($role, $requested) use ($attributes) { |
|
112 | 112 | return $attributes['changed']->toDateTime()->format('c'); |
113 | 113 | }, |
114 | - 'deleted' => function ($role, $requested) use ($attributes) { |
|
114 | + 'deleted' => function($role, $requested) use ($attributes) { |
|
115 | 115 | if (false === $attributes['deleted']) { |
116 | 116 | return null; |
117 | 117 | } |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | 'name' => (string) $attributes['username'], |
165 | 165 | 'namespace' => (string) $attributes['namespace'], |
166 | 166 | 'mail' => (string) $attributes['mail'], |
167 | - 'avatar' => function ($role, $requested) use ($attributes) { |
|
167 | + 'avatar' => function($role, $requested) use ($attributes) { |
|
168 | 168 | if ($attributes['avatar'] instanceof Binary) { |
169 | 169 | return base64_encode($attributes['avatar']->getData()); |
170 | 170 | } |
171 | 171 | |
172 | 172 | return null; |
173 | 173 | }, |
174 | - 'soft_quota' => function ($role, $requested) use ($attributes, $user) { |
|
174 | + 'soft_quota' => function($role, $requested) use ($attributes, $user) { |
|
175 | 175 | if ($user === null) { |
176 | 176 | return null; |
177 | 177 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | return null; |
184 | 184 | }, |
185 | - 'hard_quota' => function ($role, $requested) use ($attributes, $user) { |
|
185 | + 'hard_quota' => function($role, $requested) use ($attributes, $user) { |
|
186 | 186 | if ($user === null) { |
187 | 187 | return null; |
188 | 188 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | * Add decorator. |
74 | 74 | * |
75 | 75 | * |
76 | - * @return AttributeDecorator |
|
76 | + * @return RoleDecorator |
|
77 | 77 | */ |
78 | 78 | public function addDecorator(string $attribute, Closure $decorator): self |
79 | 79 | { |
@@ -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 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | return $response |
272 | 272 | ->setOutputFormat(null) |
273 | - ->setBody(function () use ($node, $offset, $limit) { |
|
273 | + ->setBody(function() use ($node, $offset, $limit) { |
|
274 | 274 | $stream = $node->get(); |
275 | 275 | $name = $node->getName(); |
276 | 276 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | return (new Response())->setCode(200)->setBody($result); |
402 | 402 | } |
403 | 403 | |
404 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
404 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
405 | 405 | return [ |
406 | 406 | 'code' => 200, |
407 | 407 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | 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 |
510 | 510 | { |
511 | 511 | $attributes = compact('name', 'meta', 'readonly', 'filter', 'acl'); |
512 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
512 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
513 | 513 | |
514 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
514 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
515 | 515 | foreach ($attributes as $attribute => $value) { |
516 | 516 | switch ($attribute) { |
517 | 517 | case 'name': |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | ); |
595 | 595 | } |
596 | 596 | |
597 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
597 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
598 | 598 | $result = $node->copyTo($parent, $conflict); |
599 | 599 | |
600 | 600 | return [ |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | ); |
656 | 656 | } |
657 | 657 | |
658 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
658 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
659 | 659 | $result = $node->setParent($parent, $conflict); |
660 | 660 | |
661 | 661 | return [ |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
706 | 706 | } |
707 | 707 | |
708 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
708 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
709 | 709 | if (null === $at) { |
710 | 710 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
711 | 711 | } else { |