@@ -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 | $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 | } |
@@ -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 | { |
@@ -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; |
@@ -194,6 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Add notification. |
| 197 | + * @param User $sender |
|
| 197 | 198 | */ |
| 198 | 199 | public function postNotification(User $receiver, ?User $sender, MessageInterface $message, array $context = []): ObjectId |
| 199 | 200 | { |
@@ -291,6 +292,7 @@ discard block |
||
| 291 | 292 | |
| 292 | 293 | /** |
| 293 | 294 | * Get subscription. |
| 295 | + * @return NodeInterface |
|
| 294 | 296 | */ |
| 295 | 297 | public function getSubscription(NodeInterface $node, User $user): ?array |
| 296 | 298 | { |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | if ($node instanceof Collection && $recursive === true) { |
| 350 | 350 | $db = $this->db; |
| 351 | - $node->doRecursiveAction(function ($child) use ($db, $subscription) { |
|
| 351 | + $node->doRecursiveAction(function($child) use ($db, $subscription) { |
|
| 352 | 352 | $subscription['node'] = $child->getId(); |
| 353 | 353 | $db->subscription->replaceOne( |
| 354 | 354 | [ |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | if ($node instanceof Collection && $recursive === true) { |
| 376 | 376 | $db = $this->db; |
| 377 | - $node->doRecursiveAction(function ($child) use ($db, $node_id, $user_id) { |
|
| 377 | + $node->doRecursiveAction(function($child) use ($db, $node_id, $user_id) { |
|
| 378 | 378 | $db->subscription->deleteOne([ |
| 379 | 379 | 'user' => $user_id, |
| 380 | 380 | 'node' => $node_id, |
@@ -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 | { |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | /** |
| 59 | 59 | * Init. |
| 60 | 60 | * |
| 61 | - * @param Decorator $role_decorator |
|
| 61 | + * @param RoleAttributeDecorator $role_decorator |
|
| 62 | 62 | */ |
| 63 | 63 | public function __construct(Server $server, Acl $acl, RoleAttributeDecorator $role_decorator) |
| 64 | 64 | { |
@@ -120,20 +120,20 @@ discard block |
||
| 120 | 120 | 'mime' => (string) $attributes['mime'], |
| 121 | 121 | 'readonly' => (bool) $attributes['readonly'], |
| 122 | 122 | 'directory' => $node instanceof Collection, |
| 123 | - 'meta' => function ($node) { |
|
| 123 | + 'meta' => function($node) { |
|
| 124 | 124 | return (object) $node->getMetaAttributes(); |
| 125 | 125 | }, |
| 126 | - 'size' => function ($node) { |
|
| 126 | + 'size' => function($node) { |
|
| 127 | 127 | return $node->getSize(); |
| 128 | 128 | }, |
| 129 | - 'path' => function ($node) { |
|
| 129 | + 'path' => function($node) { |
|
| 130 | 130 | try { |
| 131 | 131 | return $node->getPath(); |
| 132 | 132 | } catch (\Exception $e) { |
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | }, |
| 136 | - 'parent' => function ($node) { |
|
| 136 | + 'parent' => function($node) { |
|
| 137 | 137 | $parent = $node->getParent(); |
| 138 | 138 | |
| 139 | 139 | if (null === $parent || $parent->isRoot()) { |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | return $this->decorate($node->getParent(), ['id', 'name', '_links']); |
| 144 | 144 | }, |
| 145 | - 'access' => function ($node) use ($acl) { |
|
| 145 | + 'access' => function($node) use ($acl) { |
|
| 146 | 146 | return $acl->getAclPrivilege($node); |
| 147 | 147 | }, |
| 148 | - 'acl' => function ($node) use ($attributes) { |
|
| 148 | + 'acl' => function($node) use ($attributes) { |
|
| 149 | 149 | if ($node->isShareMember() && count($attributes['acl']) > 0) { |
| 150 | 150 | return $node->getAcl(); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return null; |
| 154 | 154 | }, |
| 155 | - 'share' => function ($node) { |
|
| 155 | + 'share' => function($node) { |
|
| 156 | 156 | if ($node->isShared() || !$node->isSpecial()) { |
| 157 | 157 | return null; |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return null; |
| 164 | 164 | } |
| 165 | 165 | }, |
| 166 | - 'sharename' => function ($node) { |
|
| 166 | + 'sharename' => function($node) { |
|
| 167 | 167 | if (!$node->isShared()) { |
| 168 | 168 | return null; |
| 169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | return null; |
| 175 | 175 | } |
| 176 | 176 | }, |
| 177 | - 'shareowner' => function ($node) use ($server, $fs, $decorator) { |
|
| 177 | + 'shareowner' => function($node) use ($server, $fs, $decorator) { |
|
| 178 | 178 | if (!$node->isSpecial()) { |
| 179 | 179 | return null; |
| 180 | 180 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | return null; |
| 189 | 189 | } |
| 190 | 190 | }, |
| 191 | - 'owner' => function ($node) use ($server, $decorator) { |
|
| 191 | + 'owner' => function($node) use ($server, $decorator) { |
|
| 192 | 192 | try { |
| 193 | 193 | return $decorator->decorate( |
| 194 | 194 | $server->getUserById($node->getOwner()), |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
| 210 | 210 | { |
| 211 | 211 | return [ |
| 212 | - 'created' => function ($node) use ($attributes) { |
|
| 212 | + 'created' => function($node) use ($attributes) { |
|
| 213 | 213 | return $attributes['created']->toDateTime()->format('c'); |
| 214 | 214 | }, |
| 215 | - 'changed' => function ($node) use ($attributes) { |
|
| 215 | + 'changed' => function($node) use ($attributes) { |
|
| 216 | 216 | return $attributes['changed']->toDateTime()->format('c'); |
| 217 | 217 | }, |
| 218 | - 'deleted' => function ($node) use ($attributes) { |
|
| 218 | + 'deleted' => function($node) use ($attributes) { |
|
| 219 | 219 | if (false === $attributes['deleted']) { |
| 220 | 220 | return null; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | return $attributes['deleted']->toDateTime()->format('c'); |
| 224 | 224 | }, |
| 225 | - 'destroy' => function ($node) use ($attributes) { |
|
| 225 | + 'destroy' => function($node) use ($attributes) { |
|
| 226 | 226 | if (null === $attributes['destroy']) { |
| 227 | 227 | return null; |
| 228 | 228 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | return [ |
| 253 | 253 | 'shared' => $node->isShared(), |
| 254 | 254 | 'reference' => $node->isReference(), |
| 255 | - 'filter' => function ($node) use ($attributes) { |
|
| 255 | + 'filter' => function($node) use ($attributes) { |
|
| 256 | 256 | if (null === $attributes['filter']) { |
| 257 | 257 | return null; |
| 258 | 258 | } |
@@ -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]); |
@@ -114,10 +114,10 @@ |
||
| 114 | 114 | $body->setParts([$html, $plain]); |
| 115 | 115 | |
| 116 | 116 | $mail = (new Message()) |
| 117 | - ->setSubject($message->getSubject($receiver)) |
|
| 118 | - ->setBody($body) |
|
| 119 | - ->setTo($address) |
|
| 120 | - ->setEncoding('UTF-8'); |
|
| 117 | + ->setSubject($message->getSubject($receiver)) |
|
| 118 | + ->setBody($body) |
|
| 119 | + ->setTo($address) |
|
| 120 | + ->setEncoding('UTF-8'); |
|
| 121 | 121 | |
| 122 | 122 | $type = $mail->getHeaders()->get('Content-Type'); |
| 123 | 123 | $type->setType('multipart/alternative'); |