定制 torqit/pimcore-role-creator-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

torqit/pimcore-role-creator-bundle

Composer 安装命令:

composer require torqit/pimcore-role-creator-bundle

包简介

README 文档

README

Getting started

  1. This bundle is easily installed via composer: composer require torqit/pimcore-role-creator-bundle
  2. In your config folder, add a roles.yaml file. Instructions on how to set up your roles is given below in the Roles Setup section.
  3. Make sure you register the RoleCreatorBundle in your AppKernel.php located at \src\pimcore-root\app\AppKernel.php. Registering the bundle is as easy as adding a line in the registerBundlesToCollection function, like so: $collection->addBundle(new \TorqIT\RoleCreatorBundle\RoleCreatorBundle);
  4. Run the bundle, with the command: ./bin/console torq:generate-roles

Command Options

Option Description
--without-events Suppresses all role event listeners (preAdd, postAdd, preUpdate, postUpdate) during execution. Useful when you want to avoid triggering custom event listeners while importing or syncing roles.

Example:

./bin/console torq:generate-roles --without-events

Role Setup

For this example, let's say we want to add Manager and Employee roles to our app. In your config folder, add a roles.yaml file with the following layout:

system_roles:
  Manager:
  Employee:

This will create Manager and Employee roles, both with no permissions, workspaces or allowed classes.

Basic Permissions

Using the permissions specified in the user_permission_definitions table, you can specify basic permissions per role using one of three variables:

  • included_permissions: [] An array of allowed permissions
  • excluded_permissions: [] Include all permissions on a role except for the ones specified
  • all_permissions: Include all permissions

So for example, if we wanted our manager to have full access to the app, but only allow users to see documents and assets, we would configure it like so:

system_roles:
  Manager:
    all_permissions: true
  Employee:
    included_permissions: ["documents", "assets"]

Workspaces

You can specify data object, asset and document workspaces using the following structure per role.

workspaces:
  data_objects:
    /folderName:
      permissions: []
      special_configs:
        localized_edit: "fr_CA"
        localized_view: "en,fr_CA"
        custom_layouts: "object_ProductLayout,object_SupplierLayout"
  assets:
    /folderName: []
  documents:
    /folderName: []

Where folderName is the full path to the folder for that workspace. Each workspace array can be populated with the following currently supported permissions:

  • list
  • view
  • save (Documents/Data Objects Only)
  • publish
  • unpublish (Documents/Data Objects Only)
  • delete
  • rename
  • create
  • settings
  • versions
  • properties

Note: in order to make the entire structure available, you can supply / as the folder, which will make a workspace at the root.

Going back to our example, if we wanted to make it so that the Employee role can only operate in the articles folders for documents and assets, we might set up our config this way:

system_roles:
  Manager:
    # Manager Permissions
  Employee:
    workspaces:
      data_objects:
        /articles:
          permissions: ["list", "view", "create", "save", "publish"]
      assets:
        /articles: ["list", "view"]

Alternatively, you can pass true to a workspace, which will enable all of the permissions

 ...
    workspaces:
      data_objects:
        /articles:
          permissions: true

You can specify special configurations per data object workspace:

  • Custom layouts
  • Localization
 ...
    workspaces:
      data_objects:
        /articles:
          special_configs:
            localized_edit: "fr_CA"
            localized_view: "en,fr_CA"
            custom_layouts: "object_ProductLayout,object_SupplierLayout"

Allowed Document Types & Classes

You can specify the allowed document types and classes per role using the following structure:

allowed_types:
  classes: ["MyClassName"]
  document_types: ["Document Name"]

Where the both values accept the class/document type name (and not the class/doc type ID). For example, if we wanted to make it so that the Employee role could only create Article's, we would simply specify the following:

system_roles:
  Manager:
    # Manager Permissions
  Employee:
    allowed_types:
      document_types: ["Article"]

Note: The default behavior for pimcore is that if no allowed class/doc types are specified, then all classes and doc types are allowed. If you need to restrict all creation, you may need to configure it at the workspace level.

Allowed Perspectives

You can specify the allowed perspectives on a role by adding perspectives to an array of strings:

perspectives: ["Default"]

If you don't specify a list of perspectives, than it will clear all previously selected perspectives.

License

This bundle is licensed under the Pimcore Open Core License (POCL) and is intended for use with Pimcore Platform 2025.1 and newer.

See LICENSE.md for full license text.

torqit/pimcore-role-creator-bundle 适用场景与选型建议

torqit/pimcore-role-creator-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44.4k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 torqit/pimcore-role-creator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 torqit/pimcore-role-creator-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 torqit/pimcore-role-creator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 44.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2020-10-28