Symfony2和Sonata Admin Bundle的问题 - 仪表板登录区域

时间:2014-07-05 17:35:04

标签: symfony-2.5

我有关于配置Symfony 2.5和Sonata Admin Bundle的问题。我试图修复它[在google.com上搜索,仔细阅读sonata-project.org],但问题仍然存在。所以我希望每个人都支持我解决它。

请参阅下面的详细信息:

security.yml的配置

  parameters:
      security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap

  security:
      encoders:
           FOS\UserBundle\Model\UserInterface: sha512

      role_hierarchy:
          ROLE_ADMIN:       ROLE_USER
          ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

          SONATA:
              # if you are not using acl then this line must be uncommented
              - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT
              #- ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT

      providers:
          fos_userbundle:
              id: fos_user.user_manager

      firewalls:
          # Disabling the security for the web debug toolbar, the profiler and Assetic.
          dev:
              pattern:  ^/(_(profiler|wdt)|css|images|js|admin/_(wdt|profiler)|api/_(wdt|profiler))/
              security: false

          # This firewall is used to handle the admin login area
          # This part is handled by the Sonata User Bundle
          admin:
              pattern:            /admin(.*)
              context:            user
              form_login:
                  provider:       fos_userbundle
                  login_path:     /admin/login
                  use_forward:    false
                  check_path:     /admin/login_check
                  default_target_path: /admin/dashboard
                  failure_path:   null
                  always_use_default_target_path: true
              logout:
                  path:           /admin/logout
                  target:         /admin/login
              anonymous:    true
          # This firewall is used to handle the public login area
          # This part is handled by the FOS User Bundle

      access_control:

          # Admin login page needs to be access without credential
          - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }

          # Secured part of the site
          # This config requires being logged for the whole site and having the admin role for the admin part.
          # It also secures the shop checkout process
          # Change these rules to adapt them to your needs
          - { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
          - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

      acl:
          connection: default

sonata / sonata_admin.yml的配置[此文件包含在config.yml中]

  sonata_admin:
      security:
              handler: sonata.admin.security.handler.acl
              # acl security information
              information:
                  GUEST:    [VIEW, LIST]
                  STAFF:    [EDIT, LIST, CREATE]
                  EDITOR:   [OPERATOR, EXPORT]
                  ADMIN:    [MASTER]
              # permissions not related to an object instance and also to be available when objects do not exist
              # the DELETE admin permission means the user is allowed to batch delete objects
              admin_permissions: [CREATE, LIST, DELETE, UNDELETE, EXPORT, OPERATOR, MASTER]
              # permission related to the objects
              object_permissions: [VIEW, EDIT, DELETE, UNDELETE, OPERATOR, MASTER, OWNER]

      dashboard:
          blocks:
              - { position: left, type: sonata.block.service.text, settings: { content: "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>Welcome!</h3></div><div class='panel-body'>You can customize this dashboard by editing the <code>sonata_admin.yml</code> file. The current dashboard presents the recent items from the NewsBundle and a non-statistical e-commerce information.</div></div>"} }
              - { position: right, type: sonata.block.service.rss, settings: { title: Sonata Project's Feeds, url: http://sonata-project.org/blog/archive.rss, template: SonataAdminBundle:Block:block_rss_dashboard.html.twig }}
          groups:
              sonata.admin.group.administration:
                  label:           sonata_administration
                  label_catalogue: SonataAdminBundle
                  icon:            '<i class="fa fa-cogs"></i>'
                  items:
                      - sonata.user.admin.user
                      - sonata.user.admin.group

sonata / sonata_block.yml的配置[此文件包含在config.yml中]

  sonata_block:
      default_contexts: [cms]

      blocks:
          sonata.admin.block.admin_list:
              contexts:   [admin]

          sonata.block.service.text:
          sonata.block.service.rss:

配置fos / fos_user.yml [此文件包含在config.yml]

   fos_user:
    db_driver:      orm # can be orm or odm
    firewall_name:  main

    # if you change the class configuration, please also alter the sonata_user.yml file
    user_class:     Application\Sonata\UserBundle\Entity\User

    group:
        group_class:   Application\Sonata\UserBundle\Entity\Group

routing.yml的配置

   _admin:
     resource: routing_admin.yml
     prefix:   /admin

routing_admin.yml的配置[此文件包含在routing.yml中]

admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'

_sonata_admin:
    resource: .
    type:     sonata_admin

soanata_user_admin:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'

composer.json中需要的一部分

  "require": {
      "php": ">=5.3.3",
      "symfony/symfony": "2.5.*",
      "doctrine/orm": "~2.2,>=2.2.3",
      "doctrine/doctrine-bundle": "~1.2",
      "twig/extensions": "~1.0",
      "symfony/assetic-bundle": "~2.3",
      "symfony/swiftmailer-bundle": "~2.3",
      "symfony/monolog-bundle": "~2.4",
      "sensio/distribution-bundle": "~3.0",
      "sensio/framework-extra-bundle": "~3.0",
      "incenteev/composer-parameter-handler": "~2.0",
      "sonata-project/admin-bundle": "dev-master",
      "sonata-project/doctrine-orm-admin-bundle": "dev-master",
      "sonata-project/easy-extends-bundle": "dev-master",
      "sonata-project/user-bundle": "~2.2@dev

问题的屏幕截图

请访问:https://plus.google.com/u/0/110571324794293900613/posts/fHW9fz2sYHH?pid=6032630377545776242&oid=110571324794293900613

最后,我非常感谢大家。

等你的好消息!

由于

1 个答案:

答案 0 :(得分:1)

你应该覆盖standard_layout.html.twig文件,根据你做出改变..