Sonata Admin 异常:变量 "adminPool" 不存在

Sonata Admin Exception: Variable "adminPool" does not exist

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

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] }

我是不是在配置中遗漏了什么?

看来是4.0.1版本修复的bug。 运行 composer update 今天早上修好了:

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