sidus/eav-permission-bundle

为Sidus/EAVModelBundle集成基于角色的属性级权限

v2.0.2 2019-07-09 12:47 UTC

This package is auto-updated.

Last update: 2024-09-19 20:43:07 UTC


README

此包允许您为Sidus/EAVModelBundle定义基于角色的权限。

它支持通过其家族对家族、属性和EAVData进行权限设置。(因此没有实体级权限)

快速示例

角色只是作为示例,此包中没有硬编码的角色。

sidus_eav_model:
    families:
        Post:
            attributeAsLabel: title
            options:
                permissions:
                    # list: [] # Don't define a permission: means granted for all
                    edit: [ROLE_DATA_ADMIN]
                    delete: [] # Defined but left empty: deny access for all
            attributes:
                title:
                    required: true

                content:
                    type: html

                publicationDate:
                    type: datetime
                    options:
                        permissions:
                            read: [ROLE_DATA_MANAGER]
                            edit: [ROLE_DATA_ADMIN]

家族权限

EAVModelBundle内部没有检查这些权限的规则,所以您需要通过Symfony的安全组件来检查这些权限

<?php

use Sidus\EAVModelBundle\Model\FamilyInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Sidus\EAVPermissionBundle\Security\Permission;

/** @var FamilyInterface $family */
/** @var AuthorizationCheckerInterface $securityChecker **/
$securityChecker->isGranted(Permission::EDIT, $family);

属性权限

EAVModelBundle通过表单组件原生支持属性权限。

如果没有设置权限选项,则表示该属性将对所有人可编辑。如果属性可读但不可编辑,则表单类型将显示为禁用状态