在Symfony 2内存中用户提供程序中添加自定义密钥?

时间:2014-03-16 09:12:13

标签: symfony symfony-2.4

如何在Symfony 2内存中用户提供程序中添加自定义密钥?

providers:
    administrators:
        memory:
            users:
                admin: { password: admin, roles: [ 'ROLE_USER' ] }

如果我修改上述内容,则添加image属性用户将无法再登录。真是一个奇怪的问题。

providers:
    administrators:
        memory:
            users:
                admin: { password: admin, roles: [ 'ROLE_USER' ], image: "img/plh.png" }

1 个答案:

答案 0 :(得分:4)

原因在于错误日志:

PHP Fatal error:  Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' with message 'Unrecognized options "image" under "security.providers.in_memory.memory.users.manage"' in ~/vendor/symfony/symfony/src/Symfony/Component/Config/Definition/ArrayNode.php:306

检查: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L562

要修复它,您可以扩展SecurityBundle的配置: http://symfony.com/doc/current/cookbook/bundles/prepend_extension.html