3
저는 몇 개의 컨트롤러에서 ACL을 사용하고 있으며 같은 코드를 반복해서 쓰지 않고 ACL을 사용하는 "깨끗한"방법이 있는지를 배회하고있었습니다.Symfony2 ACL이 서비스로 구현 되었습니까?
내가 얘기 해요 ACL 코드는 the sf2 cookbook.
에서
// creating the ACL
$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($comment);
$acl = $aclProvider->createAcl($objectIdentity);
// retrieving the security identity of the currently logged-in user
$securityContext = $this->get('security.context');
$user = $securityContext->getToken()->getUser();
$securityIdentity = UserSecurityIdentity::fromAccount($user);
// grant owner access
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);
수있는 좋은 아이디어는 서비스로이 코드를 구현 한 다음 필요한 경우를 확장하고, 대신 사용하는 것 각 컨트롤러에 같은 코드를 쓰는가?
사실, 이미 완료했습니다. (https://github.com/Problematic/ProblematicAclManagerBundle) – Problematic
@Problematic 링크를 사용해 주셔서 감사합니다. 지금 사용해보세요. –
감사! 이거 엄청나 네. 좋은 번들. – Tool