如何使用Symfony ACL过滤我的Doctrine查询 [英] How to filter my Doctrine queries with Symfony ACL
问题描述
Symfony ACL允许我授予对一个实体的访问权限,然后检查它:
Symfony ACL allows me to grant access to an entity, and then check it:
if (false === $securityContext->isGranted('EDIT', $comment)) {
throw new AccessDeniedException();
}
但是,如果数据库中有数千个实体,用户有权限只有10个,我不想加载内存中的所有实体并使其水合。
However, if I have thousands of entities in the database and the user has access only to 10 of them, I don't want to load all the entities in memory and hydrate them.
我如何做一个简单的SELECT * FROM X,而只对用户有权访问的实体(在SQL级别)进行过滤?
How can I do a simple "SELECT * FROM X" while filtering only on the entities the user has access (at SQL level)?
推荐答案
那就是:
Well there it is: it's not possible.
在过去一年中,我一直在使用另一种可以直接过滤数据库查询的ACL系统。
In the last year I've been working on an alternative ACL system that would allow to filter directly in database queries.
我公司最近同意开源,所以这里是: http: //myclabs.github.io/ACL/
My company recently agreed to open source it, so here it is: http://myclabs.github.io/ACL/
这篇关于如何使用Symfony ACL过滤我的Doctrine查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!