WIP work on delete/update

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-12-30 11:23:22 +01:00
parent c440b7ff7d
commit 7291c46d0d

View File

@@ -272,8 +272,19 @@ class AttachmentService {
* @throws NoPermissionException
*/
public function update($attachmentId, $data) {
if (is_numeric($attachmentId) === false) {
throw new BadRequestException('attachment id must be a number');
if (!is_numeric($attachmentId)) {
[$type, $attachmentId] = explode(':', $attachmentId);
try {
$attachment = new Attachment();
$attachment->setId($attachmentId);
$attachment->setType($type);
$attachment->setData($data);
$service = $this->getService($type);
return $service->update($attachment);
} catch (\Exception $e) {
throw new NotFoundException();
}
}
if ($data === false || $data === null) {
@@ -321,8 +332,18 @@ class AttachmentService {
* @throws BadRequestException
*/
public function delete($attachmentId) {
if (is_numeric($attachmentId) === false) {
throw new BadRequestException('attachment id must be a number');
if (!is_numeric($attachmentId)) {
[$type, $attachmentId] = explode(':', $attachmentId);
try {
$attachment = new Attachment();
$attachment->setId($attachmentId);
$attachment->setType($type);
$service = $this->getService($type);
return $service->delete($attachment);
} catch (\Exception $e) {
throw new NotFoundException();
}
}
try {