From e09f60e71fa6975154de2c1a9cf18c0c836f85de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Tue, 3 Oct 2023 23:58:41 +0200 Subject: [PATCH] Allow to filter attachments API response by attachment types --- src/ApiResource/.gitignore | 0 src/Entity/Attachments/Attachment.php | 2 ++ 2 files changed, 2 insertions(+) delete mode 100644 src/ApiResource/.gitignore diff --git a/src/ApiResource/.gitignore b/src/ApiResource/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index ae5c8b82..78789001 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; use App\ApiPlatform\DocumentedAPIProperty; +use App\ApiPlatform\Filter\EntityFilter; use App\ApiPlatform\Filter\LikeFilter; use App\Repository\AttachmentRepository; use App\EntityListeners\AttachmentDeleteListener; @@ -84,6 +85,7 @@ use LogicException; #[DocumentedAPIProperty(schemaName: 'Attachment-Read', property: 'thumbnail_url', type: 'string', nullable: true, description: 'The URL to a thumbnail version of this file. This only exists for internal picture attachments.')] #[ApiFilter(LikeFilter::class, properties: ["name"])] +#[ApiFilter(EntityFilter::class, properties: ["attachment_type"])] #[ApiFilter(DateFilter::class, strategy: DateFilter::EXCLUDE_NULL)] #[ApiFilter(OrderFilter::class, properties: ['name', 'id', 'addedDate', 'lastModified'])] abstract class Attachment extends AbstractNamedDBElement