core icon indicating copy to clipboard operation
core copied to clipboard

API - /api/contents - filter by taxonomies

Open hanzx opened this issue 3 years ago • 1 comments

Hi, would there be an option in api to filter by taxonomies?

@ApiFilter(SearchFilter::class, properties={ "id": "exact", "contentType": "exact", "status": "exact", "createdAt": "exact", "publishedAt": "exact", "depublishedAt": "exact", "taxonomies.id": "exact", "taxonomies.slug": "exact", })

hanzx avatar Feb 18 '22 12:02 hanzx

It's a bit quirky but you can decorate Bolt\Api\Extensions\ContentExtension and use the ContextAwareQueryCollectionExtensionInterface, which will pass context in applyToCollection method, allowing you to retrieve filters from this parameter and then apply it to the query builder.

jordanaubert avatar Mar 17 '22 14:03 jordanaubert