sherlockode/sonata-advanced-content-bundle

Sonata 管理集成 SherlockodeAdvancedContentBundle

v0.3.1 2020-07-28 15:27 UTC

README

Sonata Admin 集成 SherlockodeAdvancedContentBundle

安装

安装此包的最佳方式是依赖 Composer

$ composer require sherlockode/sonata-advanced-content-bundle

在应用程序内核中注册此包,并确保在 AdvancedContentBundle 之后添加此包

// config/bundles.php
<?php

return [
    /* ... */
    Sherlockode\AdvancedContentBundle\SherlockodeAdvancedContentBundle::class => ['all' => true],
    Sherlockode\SonataAdvancedContentBundle\SherlockodeSonataAdvancedContentBundle::class => ['all' => true],
];

您需要通过 webpack 和 Sonata 配置将我们特定的 CSS 和 JS 文件添加到您的应用程序中。

// assets/js/app.js

// sherlockode/advanced-content-bundle configuration
import '../../vendor/sherlockode/advanced-content-bundle/Resources/public/css/index.scss';
import '../../vendor/sherlockode/advanced-content-bundle/Resources/js/index.js';

// font awesome (optional)
import '@fortawesome/fontawesome-free/css/fontawesome.css';
import '@fortawesome/fontawesome-free/css/solid.css';

// sherlockode/sonata-advanced-content-bundle configuration
import '../../vendor/sherlockode/sonata-advanced-content-bundle/Resources/js/acb-sonata.js';
import '../../vendor/sherlockode/sonata-advanced-content-bundle/Resources/css/acb-sonata.scss';

然后,您可以将以下行添加到 Sonata 配置中

# config/packages/sonata_admin.yaml
sonata_admin:
    assets:
        extra_javascripts:
            - bundles/sherlockodeadvancedcontent/js/speakingurl.min.js
            - build/admin/admin-entry.js # Include here the path to your webpack generated admin js file
        extra_stylesheets:
            - build/admin/admin-entry.css # Include here the path to your webpack generated admin css file

安全

默认情况下,我们的管理员通过 ROLE_SUPER_ADMIN 访问。要配置您自己的角色层次结构,您可以使用以下角色

  • ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_CONTENT_[PERMISSION] : 访问内容
  • ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_PAGE_TYPE_[PERMISSION] : 访问页面类型
  • ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_PAGE_[PERMISSION] : 访问页面

例如,如果您想为 ROLE_ADMIN 授予所有权限,您可以添加

# config/packages/security.yaml
security:
    role_hierarchy:
        ROLE_ADMIN:
            - ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_CONTENT_ALL
            - ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_PAGE_TYPE_ALL
            - ROLE_SHERLOCKODE_ADVANCED_CONTENT_ADMIN_PAGE_ALL