feat: colleciton delete
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -549,7 +549,7 @@ class DefaultController extends ControllerAbstract {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||
}
|
||||
|
||||
return $this->mailManager->collectionDelete(
|
||||
$result = $this->mailManager->collectionDelete(
|
||||
$tenantId,
|
||||
$userId,
|
||||
$data['provider'],
|
||||
@@ -557,6 +557,48 @@ class DefaultController extends ControllerAbstract {
|
||||
$data['identifier'],
|
||||
$data['options'] ?? []
|
||||
);
|
||||
|
||||
if (is_bool($result)) {
|
||||
return [
|
||||
'outcome' => 'deleted'
|
||||
];
|
||||
}
|
||||
|
||||
if ($result instanceof JsonSerializable) {
|
||||
return [
|
||||
'outcome' => 'moved',
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function collectionMove(string $tenantId, string $userId, array $data): mixed {
|
||||
if (!isset($data['target'])) {
|
||||
throw new InvalidArgumentException(self::ERR_MISSING_TARGET);
|
||||
}
|
||||
if (!is_string($data['target'])) {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_TARGET);
|
||||
}
|
||||
if (!isset($data['sources'])) {
|
||||
throw new InvalidArgumentException(self::ERR_MISSING_SOURCES);
|
||||
}
|
||||
if (!is_array($data['sources'])) {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_SOURCES);
|
||||
}
|
||||
|
||||
$target = ResourceIdentifier::fromString($data['target']);
|
||||
if (!$target instanceof CollectionIdentifier) {
|
||||
throw new InvalidArgumentException('Invalid parameter: target must be provider:service:collection');
|
||||
}
|
||||
|
||||
$source = ResourceIdentifier::fromArray($data['source']);
|
||||
if (!$source instanceof CollectionIdentifier) {
|
||||
throw new InvalidArgumentException('Invalid parameter: sources must contain provider:service:collection identifiers');
|
||||
}
|
||||
|
||||
return $this->mailManager->collectionMove($tenantId, $userId, $target, $source);
|
||||
}
|
||||
|
||||
// ==================== Entity Operations ====================
|
||||
|
||||
Reference in New Issue
Block a user