@@ -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 | $parent = $node->getParent(); |
145 | 145 | |
146 | 146 | if (null === $parent || $parent->isRoot()) { |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | |
150 | 150 | return (string) $parent->getId(); |
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 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 'message' => (string) $message['body'], |
99 | 99 | 'subject' => (string) $message['subject'], |
100 | 100 | 'locale' => (string) $message['locale'], |
101 | - 'sender' => function ($message) use ($server, $role_decorator) { |
|
101 | + 'sender' => function($message) use ($server, $role_decorator) { |
|
102 | 102 | if (!isset($message['sender'])) { |
103 | 103 | return null; |
104 | 104 | } |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | return null; |
110 | 110 | } |
111 | 111 | }, |
112 | - 'created' => function ($message) { |
|
112 | + 'created' => function($message) { |
|
113 | 113 | return (new DateTime())->setTimestamp($message['_id']->getTimestamp())->format('c'); |
114 | 114 | }, |
115 | - 'node' => function ($message) use ($node_decorator, $fs) { |
|
115 | + 'node' => function($message) use ($node_decorator, $fs) { |
|
116 | 116 | if (isset($message['node'])) { |
117 | 117 | try { |
118 | 118 | return $node_decorator->decorate($fs->findNodeById($message['node']), ['id', 'name', '_links']); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | protected function setErrorHandler(LoggerInterface $logger): self |
56 | 56 | { |
57 | - set_error_handler(function ($severity, $message, $file, $line) use ($logger) { |
|
57 | + set_error_handler(function($severity, $message, $file, $line) use ($logger) { |
|
58 | 58 | $log = $message.' in '.$file.':'.$line; |
59 | 59 | |
60 | 60 | switch ($severity) { |
@@ -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 | } |
@@ -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 | } |
@@ -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, ?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); |