Replies: 3 comments 1 reply
-
|
I haven't done that before, but as a workaround you probably could make a custom Filter that does nothing when called on the other Operation - it's available in the filterProperty() parameters. Then you'd just forward the call to the filter you really want if it's the right operation? |
Beta Was this translation helpful? Give feedback.
-
|
It looks like this is actually possible by declaring a service, similar to the example in https://api-platform.com/docs/core/filters/#manual-service-and-attribute-registration services:
'app.filter.book.search':
class: 'ApiPlatform\Doctrine\Orm\Filter\SearchFilter'
arguments: [ '@doctrine', '@api_platform.iri_converter', ~, '@logger', { 'title': ~ } ]
tags: [ 'api_platform.filter' ]new GetCollection(filters: ['app.filter.book.search']),Discussion in #5665 of having an easier syntax |
Beta Was this translation helpful? Give feedback.
-
|
Thanks to #6244 it'll be possible to declare parameters on an operation-basis in API Platform 3.3. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
I would like to know if it's possible to give access to certain filters for only one GetCollection route.
Example :
#[ApiResource( operations: [ new GetCollection( // this one shouldn't have access to the "status" filter uriTemplate: '/my-collection/', name: 'api_get_collection' ), new GetCollection( // this one should have access to more filters like on "status" for instance name: 'api_user_get_collection', uriTemplate: '/users/my-collection/', provider: MyProvider::class ) ] )] #[ApiFilter(filterClass: OrderFilter::class, properties: ['publicationDatetime' => OrderFilterInterface::DIRECTION_DESC])] // default order everyone have : order on date #[ApiFilter(filterClass: SearchFilter::class, properties: ['category' => SearchFilterInterface::STRATEGY_EXACT])] // default filter everyone have : search item on specific category class Post { private $id; private Category $category; private ?DateTimeInterface $publicationDatetime = null; private int $status = self::STATUS_DRAFT; }Does anyone have face this kind of needs ?
Thank you for
Beta Was this translation helpful? Give feedback.
All reactions