aldaflux/user-role-type-bundle

Synfony 表单类型用于用户角色...

安装: 538

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v0.1.4 2024-03-06 16:07 UTC

This package is auto-updated.

Last update: 2024-09-06 17:27:03 UTC


README

需求

安装

步骤 1 : 下载包

打开命令行控制台,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本

composer require aldaflux/user-role-type-bundle:dev-master

如果您的系统中已安装 composer,则使用此命令。

使用方法

表单类型

use  Aldaflux\AldafluxUserRoleTypeBundle\Form\Type\UserRoleType;
$builder->add("roles", UserRoleType::class); // use default configuration
$builder->add("roles", UserRoleType::class, ['config'=>"myconfigsuper"]); // use personnal configuration
$builder->add("roles", UserRoleType::class, ['config'=>"myconfigsuper", 'profile'=>"default"]); // use personnal configuration but overide the profiles

CONFIG

  • display [all|standard|'minimum']
    • all: 显示所有可用的角色,如果 security 设置为 :strict,则禁用一些角色
    • standard: 显示当前用户被授予的所有角色,如果 security 设置为 :strict,则禁用一些角色
    • minimum: 显示当前用户和编辑的用户被授予的所有角色,如果 security 设置为 :strict,则禁用一些角色

可用的角色是层次结构中的所有角色,除非在配置或构建器中配置了配置文件

  • display [all|standard|minimum]

    • all: 显示所有可用的角色,如果 security 设置为 :strict,则禁用一些角色
    • standard: 显示当前用户和编辑的用户被授予的所有角色,如果 security 设置为 :strict,则禁用一些角色
    • minimum: 显示当前用户和编辑的用户被授予的所有角色,不显示其他角色
  • label

    • display : [asItIs|word|traduction]
      • asItIs : ROLE_USER, ROLE_ADMIN, ROLE_SUPER_ADMIN
      • word : 用户,管理员,超级管理员
      • traduction : user.roles.role_user, user.roles.role_admin, user.roles.role_super_admin

如果启用 traduction,可以使用 messages+intl-icu.en

user:
    roles:
        role_user: A standard user
        role_admin: Adminstrator of the site

aldaflux_user_role_type.yaml 示例

类型可以在没有此文件的情况下工作,但对于特定的配置/配置文件

    aldaflux_user_role_type:
	    configs:
	        default:
	            display: standard #by default , optionnal [all|standard|minimum]
	            security_checked: true #by default, optionnal
	        myconfigsuper:
	            display: all
	            profile: myprofilesuper # if not set : all the roles in hierarchy
	            security_checked: false # the user can grant whith role he hasn't... dont do that
                myconfigspecific:
	            display: minimum
	    profiles:
	        myprofile: [ROLE_ADMIN, ROLE_USER, ROLE_EDITOR]
	        myprofilesuper: [ROLE_SUPER_ADMIN,ROLE_ADMIN, ROLE_USER, ROLE_EDITOR]
	    label:
	        display: traduction #by default, optionnal, [asItIs|word|traduction]
	        translation_prefixe: "user.roles." #by default, optionnal, used if display:traduction