2014-03-13 3 views
0

주어진 사용자와 관련된 모든 acl을 삭제하고 싶습니다. 나는 그것을하는 방법을 설명하는 흥미로운 출판물을 발견했다. https://groups.google.com/forum/#!topic/symfony2/mGTXlTWiMs8/discussion 그러나 이것은 잘 청소되지 않는다.Symfony2 사용자 삭제시 acl 삭제

acl_entries 및 acl_security_identites와 일치하는 항목을 삭제하고 acl_object_identities를 남깁니다. 내 AclProvider.php에서 sid (보안 ID)를 통해 개체 ID를 삭제하는 방법을 찾았지만 아무 것도 발견하지 못했습니다.

아이디어가 있으십니까?

답변

2

이 지금 아주 오래된 비슷한 할,하지만 난 생각 마침내 대답은 내 두 센트 드롭 줄 필요를 위해서.

Symfony의 문서에 언급 된 것처럼 실제로 간단합니다. SecurityIdentity를 삭제하면 ACE가 삭제된다는 것을 보장 할 수 있습니다.

그래서 가장 쉬운 방법은 당신의 서비스에 aclProvider을 주입하는 것입니다

<?php 
namespace acme\acmeBundle\Listener; 

use Symfony\Component\Security\Acl\Dbal\MutableAclProvider, 
    Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; 
use Doctrine\ORM\Event\LifecycleEventArgs; 
use acme\acmeBundle\Entity\User; 

class UserListener 
{ 
    protected $aclProvider; 

    public function __construct(MutableAclProvider $aclProvider){ 
     $this->aclProvider = $aclProvider; 
    } 

    public function postRemove(User $user, LifecycleEventArgs $event) {  
     $securityId = UserSecurityIdentity::fromAccount($user); 
     $this->aclProvider->deleteSecurityIdentity($securityId); 
    } 
} 

그리고 지금, 당신은 사용자가 삭제 한 SecurityIdentity를을 :

core.services.userListener: 
    class: acme\acmeBundle\Listener\UserListener 
    arguments: ["@security.acl.provider"] 
    tags: 
     - { name: doctrine.orm.entity_listener, lazy: true } 

그런 다음 서비스의 뜻은 다음과 같다

ACE가 연결된 모든 ACE가 제거됩니다.