Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete ACL when deleting an entity in Symfony2

Tags:

symfony

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

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?

like image 636
David Morales Avatar asked Aug 26 '11 15:08

David Morales


1 Answers

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

$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($entity);
$aclProvider->deleteAcl($objectIdentity);
like image 171
David Morales Avatar answered Nov 09 '22 22:11

David Morales