project-a/acl-bundle

此包已被废弃,不再维护。未建议替代包。

提供与Symfony Security Acl轻松工作的便捷方式。

安装: 1,412

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 5

分支: 4

开放问题: 0

类型:symfony-bundle

v1.1.0 2015-09-10 21:28 UTC

This package is not auto-updated.

Last update: 2019-08-20 21:56:59 UTC


README

为Symfony2提供的访问复杂ACL子系统的包

Latest Stable Version Total Downloads License Build Status Coverage Status SensioLabsInsight

描述

此Symfony 2 Bundle提供了一个易于使用的API来访问Security/ACL组件,并在删除域对象时自动清理ACL的事件监听器。安装简单,默认情况下不会更改应用程序的任何行为。

没有这个包,你通常会这样做(来自ACL文档

// creating the ACL
$aclProvider = $container->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($domainObject);
$acl = $aclProvider->createAcl($objectIdentity);

// retrieving the security identity of the currently logged-in user
$tokenStorage = $container->get('security.token_storage');
$user = $tokenStorage->getToken()->getUser();
$securityIdentity = UserSecurityIdentity::fromAccount($user);

// grant owner access
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);

有了这个包,你可以简化为

$tokenStorage = $container->get('security.token_storage');
$user = $tokenStorage->getToken()->getUser();

$aclManager = $container->get('projecta_acl.manager');
$aclManager->manageObjectAces()
    ->grant($domainObject, MaskBuilder::MASK_OWNER, $user);

文档

最新的文档可以在aclbundle.chililabs.org找到。

测试

要运行测试套件,你需要composer

$ composer install
$ phpunit

许可

ChiliLabs AclBundle在MIT许可下授权。