1 year ago

#355281

test-img

Lama

ApiPlatform - Disable a Doctrine filter when any ToOne relation is fetched

Just implemented SoftDeleteable doctrine extension along with API Platform framework and here is my problem :

So basically, the SoftDeleteable bundle comes with a doctrine filter that adds a deletedAt IS NOT NULL part to every query

But I want to still be able to fetch removed items if they're fetched from another entity's ToOne relation. Collections should still be using the doctrine filter. Let me show you an example, so you can understand better:

Person is an entity that contains some attributes and a Book $favoriteBook OneToOne relation. When the book is deleted I don't want it to appear in my book list, but I still want it to be fetched from the Person's favoriteBook attribute

Also, same thing should happen when retrieving a Book from a Person whose author got deleted

I thought it would be a good solution to disable the softdeleatable filter upon fetching a ToOne relation, but I can't seem to find an event that triggers every time a relation / attribute has to be fetched

symfony

doctrine-orm

doctrine

api-platform.com

soft-delete

0 Answers

Your Answer

Accepted video resources