I’ve two classes with a custom filter:
/**
* @ORMEntity()
* @ORMInheritanceType("SINGLE_TABLE")
* @ORMDiscriminatorColumn(name="type", type="string")
* @ORMDiscriminatorMap({"store" = "Store", "book_store" = "BookStore"})
* @ApiResource(normalizationContext = {"groups" = {"api_read"}}, collectionOperations = {"GET"}, itemOperations = {"GET"})
* @ApiFilter(OrSearchFilter::class, properties={"title", "text"})
*/
class Store
{
...
}
/**
* @ORMEntity
* @ApiResource(normalizationContext = {"groups" = {"api_book_read", "api_read"}}, collectionOperations = {"GET"}, itemOperations = {"GET"})
* @ApiFilter(OrSearchFilter::class, properties={"title", "text", "book.book.authors.title", "book.book.theme.title"})
*/
class BookStore extends Store {
...
}
When I try to filter on my entity ‘BookStore’, my filter ‘OrSearchFilter’ is called twice: the first SQL query is for ‘BookStore’ and the second for ‘Store’. So, if I try to filter on ‘book.book.authors.title’, I have no result because Api-Platform calls my ‘OrSearchFilter’ of my entity ‘Store’.
How to make my filter only be called once for my entity ‘BookStore’?