Sonata Admin Exception:变量“adminPool”不存在

时间:2017-12-19 13:29:45

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

升级到较新版本的SonataAdminBundle和SonataUserBundle后,点击登录页面中忘记密码?链接时出现此异常:

CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "Variable "adminPool" does not exist." at /home/luca/Sites/redken_cms/vendor/sonata-project/user-bundle/src/Resources/views/Admin/Security/Resetting/request.html.twig line 31

这些是我的作曲家包版本:

sonata-project/admin-bundle              3.29.0  The missing Symfony Admin ...
sonata-project/block-bundle              3.9.0   Symfony SonataBlockBundle
sonata-project/cache                     2.0.1   Cache library
sonata-project/core-bundle               3.8.0   Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1   Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2   Doctrine2 behavioral exten...
sonata-project/doctrine-orm-admin-bundle 3.3.0   Symfony Sonata / Integrate...
sonata-project/easy-extends-bundle       2.3.0   Symfony SonataEasyExtendsB...
sonata-project/exporter                  1.8.0   Lightweight Exporter library
sonata-project/media-bundle              3.10.0  Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0   Symfony SonataNotification...
sonata-project/user-bundle               4.0.0   Symfony SonataUserBundle
symfony/symfony                          v2.8.32 The Symfony PHP framework

这些是我在config.yml中的设置:

sonata_user:
    security_acl: true
    manager_type: orm # can be orm or mongodb

    class:
        user: Application\Sonata\UserBundle\Entity\User
        group: Application\Sonata\UserBundle\Entity\Group

fos_user:
    db_driver:      orm # can be orm or odm
    firewall_name:  main
    user_class:     Application\Sonata\UserBundle\Entity\User

    group:
        group_class:   Application\Sonata\UserBundle\Entity\Group
        group_manager: sonata.user.orm.group_manager                    # If you're using doctrine orm (use sonata.user.mongodb.group_manager for mongodb)

    service:
        user_manager: sonata.user.orm.user_manager                      # If you're using doctrine orm (use sonata.user.mongodb.user_manager for mongodb)

    from_email:
        address: "%mailer_from_address%"
        sender_name: "%mailer_from_sender_name%"

这些是我在security.yml中的设置:

security:
    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        SONATA:
            - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

    # https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        # -> custom firewall for the admin area of the URL
        admin:
            pattern:            /admin(.*)
            context:            user
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
            logout:
                path:           /admin/logout
                target:         /admin/login
            anonymous:          true

        # -> end custom configuration

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    acl:
        connection: default

    access_control:
        # Admin login page needs to be accessed without credential
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/resetting, 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.
        # Change these rules to adapt them to your needs
        - { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }

我是否遗漏了配置中的内容?

1 个答案:

答案 0 :(得分:1)

似乎这是4.0.1版中修复的错误。今天早上运行composer update修正了它:

https://github.com/sonata-project/SonataUserBundle/releases/tag/4.0.1

enter image description here