在Symfony 4的Sonata管理页面中创建新页面

时间:2018-10-26 10:27:40

标签: php symfony sonata-admin sonata symfony-sonata

我有一个要修改的现有Symfony 4应用程序。我想添加一个新页面,并在左侧栏中包含指向该页面的链接 https://image.ibb.co/dZnjbV/Capture.jpg

我的sonata_admin.yaml看起来像这样

sonata_admin:
  title:                'GPAC'
  title_logo:           img/logo.png
  templates:
    layout:       "base.html.twig"
    dashboard:    "Core/dashboard.html.twig"
    list_block:   "Block/block_admin_list.html.twig"
    edit:         "CRUD/edit.html.twig"
    list:         "CRUD/list.html.twig"
  options:
    title_mode: 'single_text'
  security:
    handler: sonata.admin.security.handler.role
    role_admin: ROLE_ADMIN
    role_super_admin: ROLE_SUPER_ADMIN
  dashboard:  
    blocks:
      -
        position: left
        type: sonata.block.service.template
        settings:
          template: "Block/block_alert.html.twig"
      -
        position: right
        type: sonata.block.service.template
        settings:
          template: "Block/block_activity.html.twig"
    groups:
      admin:
        label: 'Administration'
        icon: '<i class="fa fa-database"></i>'
      skill:
        label: 'Matrice de compétences'
        icon: '<i class="fa fa-tasks"></i>'
      rc:
        label: 'Gestion des ressources'
        icon: '<i class="fa fa-user-circle-o"></i>'
      frc:
        label: 'Suivi de compétence des ressources'
        icon: '<i class="fa fa-search"></i>'
      client:
        label: 'Client (OEC)'
        icon: '<i class="fa fa-building-o"></i>'
      project:
        label: 'Gestion d''acréditation'
        icon: '<i class="fa fa-folder-open-o"></i>'
      council:
        label: 'Comités & Réunions'
        icon: '<i class="fa fa-calendar"></i>'


  assets:
    extra_stylesheets:
      - bundles/sonataadmin/vendor/admin-lte/dist/css/skins/_all-skins.min.css
    remove_stylesheets:
      - bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css

sonata_block:
#   default_contexts: [cms]
  blocks:
    sonata.admin.block.admin_list:
      contexts: [admin]
    sonata.admin.block.search_result:
      contexts: [admin]
    sonata.block.service.text:
      contexts: [admin]
    sonata.block.service.template:
      contexts: [admin]

我的 src 文件夹就像这个https://image.ibb.co/eBFHVq/Capture2.jpg

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

要添加自定义管理页面: 您可以执行与Symfony非常相似的操作:

  1. 创建扩展AbstractAdmin的Sonata Admin类
  2. 您必须在其中定义基本路由模式和路由名称
  3. 将操作添加到该控制器,然后生成模板(渲染)
  4. 定义并创建将返回到您的模板的实体和方法
  5. 使用参数和标签将它们注册到您的services.yml中
  6. 您需要将此新块添加到config.yml(sonata_block)
  7. 当然也创建您的树枝模板(扩展了Sonata的standard_layout树枝)

here找到kunicmarko20的完整示例