我想覆盖 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%
但它不起作用,找不到路线
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>
这可行,但我不知道如何从parameter.yml 传递我的语言环境参数
首先,yaml 路由不起作用,因为 FOSUserBundle 路由是在 xml 中定义的。
所以你的 yaml 路由不会被导入。
这里是 FOSUserBundle 路由:https://github.com/FriendsOfSymfony/FOSUserBundle/tree/master/Resources/config/routing 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
进一步回答最后一点如何将区域设置传递到路由中的信息如下: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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)