Symfony2 ACL和寻呼机/多重实体过滤 [英] Symfony2 ACL and pager/multiple entities filtering

查看:128
本文介绍了Symfony2 ACL和寻呼机/多重实体过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了一些ACL来处理一个实体的例子,但是没有一个可以处理获取多个项目,例如属于作者的帖子列表。一个(坏)的建议是获取所有项目,然后使用acl进行过滤 - 当我们有一百万个项目时不会工作。获取多个项目的方法是什么 - 假设我想要为寻呼机分批获取所有的帖子(使用我所需要的任何条件,如已发布或订购的)50个(为什么后置过滤不起作用的另一个原因)

解决方案

我想,你不应该使用ACL来确定哪些帖子属于到一个特定的作者,因为ACL是关于访问控制/权限,而不是关于查找所有者或确定对象关系。



但当然你完全可以想要获取某些用户可以查看,编辑或调整的帖子列表。



目前,在API级别上没有这样做的功能,但是...我认为在Symfony2 / Doctrine2中,您可以只做本地查询,并加入 acl_entries表



c> acl_entries 表将包含太多的行,加入它可能很慢(我们知道MySQL有时是愚蠢的)。所以你也可能想要围绕这个建立一些缓存系统。


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).

解决方案

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.

这篇关于Symfony2 ACL和寻呼机/多重实体过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆