I'm using voters to check if a user has the correct permissions to perform a certain action on a entity.
CRUD actions are easy to check. But how do I check the permissions on result sets or overviews. The overviews use pagination with PagerFanta to paginate the results. Checking the results beforehand won't be possible because of performance issues. Only checking the results which have been return in pagination could lead to empty or half empty pages.
I'm thinking of putting the same validation in my repository so they only return results the users is allowed to see. But this creates code duplication because the same validation is now duplicated, once in a voter and once in a repository.
Is there a better solution to this or aren't voters the best solution for this?