【问题标题】:FOSUserBundle Translate route nameFOSUserBundle 翻译路由名称
【发布时间】:2016-07-11 02:03:09
【问题描述】:

您好,我正在将 FOSUserBundle 的路由与 SonataUserBundle 一起使用。哪些是英文的。 我想把它们翻译成法语。

我是在 routing.yml 中完成的

sonata_user_resetting:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
    prefix: /reset

sonata_user_profile:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
    prefix: /mon-compte

sonata_user_register:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
    prefix: /inscription

sonata_user_change_password:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
    prefix: /mon-compte

sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

sonata_user_admin_security:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

sonata_user_admin_resetting:
    resource: '@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml' # et non 'admin_resetting.xml' : erreur dans la doc
    prefix: /admin/reset

但我看不到在哪里可以配置 /login 路由。

你有想法吗?

编辑:

我的 AppKernel.php

$bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new FM\AppBundle\AppBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            // These are the other bundles the SonataAdminBundle relies on
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            // Storage and SonataAdminBundle
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle(),
            new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
            new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
            new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
        );

Application\Sonata\UserBundle\ApplicationSonataUserBundle 是托管我的用户实体的捆绑包。

【问题讨论】:

    标签: symfony fosuserbundle sonata-user-bundle


    【解决方案1】:

    登录路径在FOS/UserBundle/Resources/config/routing/security.xml中定义。

    示例代码更改:

    fos_user_security_login:
        path:      /yourpath/login
        defaults:  { _controller: FOSUserBundle:Security:login, _method: POST }
    

    在此处阅读有关覆盖 FOSUserBundle 路由的更多信息:http://symfony.com/doc/current/bundles/FOSUserBundle/routing.html

    【讨论】:

    • 它在我创建新路线时起作用。但是路由登录仍然可用,即使我将security.yml中的路由名称更改为login_path:/my-new-name
    • 首先确保你的包在 FOSUserBundle 之后被初始化(然后它应该覆盖以前的同名路由)。
    • 我做到了,我已经编辑了我的帖子。但还是同样的问题。
    • 是的。我做到了。 /login 路由仍然可用:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 2010-09-22
    • 2017-04-15
    • 2018-09-02
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多