Overriding FOSUserBundle Symfony2 Routes

I would like to redefine some routes from FOSUserBundle

MyBundle/Resources/config/routing/security.yml

fos_user_security_login:
    path:     /{_locale}/login
    defaults: { _controller: FOSUserBundle:Security:login }
    requirements:
        _locale: %locales%

fos_user_security_check:
    path:     /login_check
    defaults: { _controller: FOSUserBundle:Security:check }
    requirements:
        _locale: %locales%

fos_user_security_logout:
    path:     /{_locale}/logout
    defaults: { _controller: FOSUserBundle:Security:logout }
    requirements:
        _locale: %locales%

But this does not work, the route was not found.

MyBundle/Resources/config/routing/security.xml

<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

    <route id="fos_user_security_login" pattern="/{_locale}/login">
        <default key="_controller">FOSUserBundle:Security:login</default>
    </route>

    <route id="fos_user_security_check" pattern="/login_check">
        <default key="_controller">FOSUserBundle:Security:check</default>
        <requirement key="_method">POST</requirement>
    </route>

    <route id="fos_user_security_logout" pattern="/{_locale}/logout">
        <default key="_controller">FOSUserBundle:Security:logout</default>
    </route>

</routes>

This works, but I don't know how to pass my locales parameter from parameter.yml parameter

+4
source share
1 answer

First of all, yaml routes do not work, because FOSUserBundle routes are defined in xml. This way yaml routes will not be imported.

here are the FOSUserBundle routes: https://github.com/FriendsOfSymfony/FOSUserBundle/tree/master/Resources/config/routing

FOSUserBundle , FOSUserBundle. : http://symfony.com/doc/current/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-etc

, , , : http://symfony.com/doc/current/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-etc

<route id="contact" path="/{_locale}/contact">
    <default key="_controller">AcmeDemoBundle:Contact:index</default>
    <requirement key="_locale">%locales%</requirement>
</route>
+7

All Articles