删除Symfony2中的实体时删除ACL

时间:2022-10-16 18:30:21

Following this entry in the cookbook, the ACL system is easy to implement for an entity: http://symfony.com/doc/current/cookbook/security/acl.html

在食谱中输入此条目之后,ACL系统很容易为实体实现:http://symfony.com/doc/current/cookbook/security/acl.html

Ok, now let's say that I delete the entity (I mean, a row of my database). Why are ACL still there? How could I delete its related ACL to maintain my database clean?

好的,现在让我们说我删除了实体(我的意思是,我的数据库的一行)。为什么ACL还存在?我如何删除其相关的ACL以保持我的数据库干净?

1 个解决方案

#1


11  

After research, I have found a clean solution that works:

经过研究,我找到了一个有效的清洁解决方案:

$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($entity);
$aclProvider->deleteAcl($objectIdentity);

#1


11  

After research, I have found a clean solution that works:

经过研究,我找到了一个有效的清洁解决方案:

$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($entity);
$aclProvider->deleteAcl($objectIdentity);