Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 ACL and pager/multiple entities filtering

I've seen examples of ACL to deal with one entity but none to deal with fetching multiple items - such as a list of posts that belong to an author. One (bad) suggestion was to fetch all the items and then filter using acl - not going to work when we have a million items. What is the intended way to fetch multiple items - let's say I want to fetch all my posts (using any criteria I need such as published or ordered by) in batches of 50 for the pager (another reason why post filtering will not work - I'd end up with different page sizes).

like image 630
cyberwombat Avatar asked Sep 11 '11 01:09

cyberwombat


1 Answers

I think, you shouldn't use ACL for determining which posts belong to a particular author because ACL is about access control / permissions, not about finding owners or determining object relations.

But certainly, you are perfectly ok to want to get a list of posts certain user can view, edit or moderate for example.

Currently, there is no functionality to do this on API level, but... well, I think in Symfony2 / Doctrine2 you can just do Native Query and join with acl_entries table.

But there is a drawback. In a large system acl_entries table will contain just too much rows and joining against it can be slow (we know, that MySQL is stupid sometimes). So you might also want to build some kind of caching system around this.

like image 127
Vladislav Rastrusny Avatar answered Sep 21 '22 02:09

Vladislav Rastrusny