contextualcode / ezplatform-role-inheritance-bundle
提供用户角色继承的eZ Platform组件包。
v1.0.3
2019-04-14 04:46 UTC
Requires
- doctrine/orm: ^2.6.3
- ezsystems/ezpublish-kernel: ^7.0
This package is not auto-updated.
Last update: 2024-09-24 06:46:45 UTC
README
这是一个提供用户角色继承的eZ Platform组件包。
这与内置的用户组继承不同,因为它允许进行细粒度、易于管理的用户角色管理,而不依赖于组。
(这是从permissions-inheritance-bundle迁移到eZ Platform的。)
安装
- 运行
composer require
$ composer require contextualcode/ezplatform-role-inheritance-bundle
- 在
app/AppKernel.php
文件中启用此组件包,在registerBundles
方法中添加以下行
public function registerBundles()
{
$bundles = array(
...
new ContextualCode\EzPlatformRoleInheritanceBundle\ContextualCodeEzPlatformRoleInheritanceBundle(),
);
- 将路由添加到你的
app/config/routing.yml
contextual_code_ez_platform_role_inheritance: resource: "@ContextualCodeEzPlatformRoleInheritanceBundle/Resources/config/routing.yml" prefix: /
- 创建新的自定义数据库表
$ cat vendor/contextualcode/ezplatform-role-inheritance-bundle/src/ContextualCode/EzPlatformRoleInheritanceBundle/SQL/MySQL/schema.sql | mysql -u <username -p<password> <database_name>
注意:如果你是从使用contextualcode/permissions-inheritance-bundle的eZ 5.x安装升级,请运行升级SQL以保留你的旧角色继承
$ cat vendor/contextualcode/ezplatform-role-inheritance-bundle/src/ContextualCode/EzPlatformRoleInheritanceBundle/SQL/MySQL/upgrade.sql | mysql -u <username -p<password> <database_name>
- 完成。
使用方法
- 只需在管理UI中打开角色视图页面。在“角色继承”标签页中会有添加父/子角色的新功能。
- 还需要执行额外的代码来分配继承的角色:你必须调用RoleInheritanceService的
handleUserChildRoles($userId)
函数。你可以使用自定义登录处理器/事件监听器或其他任何方式调用该代码。例如,你可以创建一个扩展eZ\Publish\Core\MVC\Symfony\Security\User\Provider
的AppBundle\Security\User\Provider.php
。在构造函数中添加RoleInheritanceService,并覆盖refreshUser
函数以添加这些行来加载继承的角色$userId = $user->getAPIUser()->contentInfo->id; $this->roleInheritanceService->handleUserChildRoles($userId);
然后你必须将
security.providers.ezpublish.id
设置为使用此新提供者的ID。现在用户将继承在管理UI中设置的角色。