I don’t believe there’s a default way of doing this. What you could do is to write your own service that adds a Filter to your Doctrine DQL queries.
For more info, see:
- https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/filters.html
- https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/dql-custom-walkers.html
Hope this helps!