【发布时间】:2012-04-03 14:28:12
【问题描述】:
文档缺少有关ACL 的一些详细信息。就像在持久化域对象后在域对象上调用 createAcl 一样简单。然后在用户/对象上放置一个带有insertObjectAce 的掩码。
但是 Symfony2 内部如何管理 ACL?表格中是否添加了一些额外的列?
$entityManager = $this->get('doctrine.orm.default_entity_manager');
$entityManager->persist($comment);
$entityManager->flush();
// 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);
【问题讨论】:
标签: security doctrine symfony doctrine-orm acl