title: Could doctrine provide records filtered by user roles, groups or permissions?
body: <p>I've a project with a huge amount of data. I need to make query based on user role/group/permission. This means that a query like</p>
  
  <pre><code>$fooRepository = $this-&gt;getDoctrine()
      -&gt;getManager()
      -&gt;getRepository(Foo::class)
      -&gt;findAll();
  </code></pre>
  
  <p>should return different records if done by a ROLE_SUPER_ADMIN or by  ROLE_USER. Also, I need to filter record based on relations and so on.</p>
  
  <p>I've different solution in mind:</p>
  
  <ul>
  <li>inject user role inside the repository's query</li>
  <li>create a role based repository</li>
  <li>create a query for each role</li>
  </ul>
  
  <h2>Inject user role in repository's query</h2>
  
  <p>In this case each repository should be responsible to provide right data. This is a solution similar <a href="https://stackoverflow.com/questions/23747697/symfony2-create-a-doctrine-filter-to-select-current-user-data">to this</a>. In that solution record are filtered by tenant.</p>
  
  <h2>Create role based repository</h2>
  
  <p>In this case I'll need to create different repositories and instantiate them differently. But I don think this can be easy in doctrine? while I am writing, ... I am thinking this is an exaggerated solution.</p>
  
  <h2>Create queries for each roles</h2>
  
  <p>At the moment I think this is the more natural way to do queries. I just imagine that a repository should contain</p>
  
  <pre><code>+ findAllStuffForGuestRole()
  + findAllStuffForAdminRole()
  </code></pre>
  
  <p>Each time I need to add a query, I MUST create different queries.</p>