覆盖 FOSUserBundle 路由 Symfony2

2024-02-28

我想覆盖 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(使用前将#替换为@)

覆盖 FOSUserBundle 路由 Symfony2 的相关文章

随机推荐

  • 如何使用node.js在html中执行外部javascript文件

    我是一个完整的node js新手 正在努力学习基础知识 我有一个html文件 我想在本地主机环境中使用node js在html页面中调用外部javascript文件 你的主文件应检查请求的 url 是否要求 html js 或 css 文件
  • vcpkg 与 MinGW?

    我喜欢 vcpkg 的想法 但我想我更愿意坚持使用 MinGW 作为我的编译器 我找不到任何关于是否可以设置 或如何设置 vcpkg 以便它为 MinGW 而不是 MSVC 编译包的资源 如果可能的话 有人能给我指出正确的方向吗 有一些关于
  • 从 PHP exec() 函数读取 git Push 的输出

    我正在为我的框架的命令行工具编写部署命令 它使用git来部署 我有一行这样做 exec git push remote branch branch shell output status 我想要里面的推送输出 shell output 但它
  • 在VB6中,声明的字段有默认值吗?

    我正在查看一些旧的 VB6 代码 在多种形式中 我遇到了如下声明语句 PEC NUM ENT 1 As Byte EC MORE RW EXIST 0 As Byte EC CODE IND 0 As Byte EC DATA 7 As P
  • PHP - 数据库模式:版本控制、分支、迁移

    我正在尝试提出 或找到 一个可重用的系统 用于 php 项目中的数据库模式版本控制 有许多可用于 php 的 Rails 风格的迁移项目 http code google com p mysql php migrations http co
  • HTML5 音频的 ontimeupdate 在 Chrome 中未触发

    我有以下代码 用于创建 html5 音频元素并设置时间更新时的侦听器 音频在所有浏览器中都能正常播放 但 ontimeupdate 函数在 Chrome 中永远不会触发 包括 Android 上的 Chrome var audioEleme
  • 为什么在 Kotlin 中异步设置视图尺寸不起作用?

    这有效 myView layoutParams myView layoutParams apply height 100 但这都不是 使用 android ktx myView doOnLayout myView layoutParams
  • 无法在桌面应用程序背后的代码中绑定网格视图

    我有一个列出所有客户的网格视图 我将它绑定在放置在 MDI 子项中的 Form 的加载时间中 网格视图中的列是在设计时预定义的 我的代码Form Load 事件是 try cn db createConnection if cn State
  • ViewModel 没有零参数构造函数错误 - 即使它有零参数构造函数

    我是 Android 和 Java 新手 正在尝试制作一个基于位置的应用程序 EDIT 我做了一个非常非常简单的测试代码 但得到了同样的错误 这是java package com example viewmodeltest import a
  • 从电子邮件中的链接启动 iPhone 应用程序

    我一直在尝试 iPhone SDK 中的 URL 方案 并且我已经使用自定义 URL 方案 例如 myap Dosomething 来启动我的应用程序 但这对于我想要的东西来说并不实际 是否可以以某种方式注册一个方案 允许电子邮件中的链接
  • 与assert_select相反?

    我正在编写一个应用程序 需要检查视图是否存在not具有某些功能 特别是因为该功能必须仅呈现给特定安全组中的用户 我正在寻找与assert selects相反的内容 以便看到菜单是not呈现 看看这里的文档 http apidock com
  • java优先级队列与链表的比较

    我正在解决BFS问题 我使用了 PriorityQueue 但我得到了错误的答案 然后我使用了LinkedList 我猜对了并且 我无法找到它们之间的区别 这是两个代码 为什么两个答案不同 Code1 LinkedList q new Li
  • 如何创建一个 React Native ios 共享扩展应用程序

    我希望我的反应本机应用程序可以从 Whatsapp Skype 照片共享 我尝试使用反应本机共享扩展 https www npmjs com package react native share extension但它只在 Safari 浏
  • watchOS 2.2 应用程序如何确定其配对的 iPhone 是否已切换到另一台 Apple Watch?

    我正在尝试在我的 iOS 9 3 watchOS 2 2 应用程序中支持与多个手表配对的新功能 它似乎运行良好 只是我无法弄清楚 watchOS 应用程序如何确定配对的 iPhone 是否已切换到另一台 Apple Watch The do
  • 从 NSBundle 获取 nil 路径

    我在项目中创建了一个新文件夹 在其中复制了图像 称为 io jpg 我还检查了构建阶段 gt 复制捆绑资源 文件就在那里 所以我试图获取这张图片的路径 NSBundle bundle NSBundle mainBundle NSString
  • ActiveMQ如何处理关闭的会话

    我正在使用 ActiveMQ 将电子邮件消息排入队列 消费者读取队列并发送电子邮件 在启动时 我注册一个生产者并永久缓存它 PooledConnectionFactory factory new PooledConnectionFactor
  • 词法或处理器问题:未找到 boost/config/user.hpp' 文件

    当我在 Xcode 中运行 React Native 应用程序时 它显示错误 boost config user hpp 文件未找到 而且当我使用命令 react native run ios 运行应用程序时 我在终端中收到错误 Comma
  • gdax-java 作为库的实现

    我正在尝试实现这个API https github com robevansuk gdax java https github com robevansuk gdax java以便能够通过 Coinbase 创建订单 提取资金和存入资金并在
  • 在ANDROID中打开一个activity而不在manifest文件中声明它?

    我想打开一个活动而不在清单文件中声明它 我不知道这是否可能 我真正想要的是使用意图从我的程序中动态打开一个活动 如果可能的话 任何人都可以帮助我吗 不可能 虽然我不确定你的意思是 动态打开活动 See http developer andr
  • 覆盖 FOSUserBundle 路由 Symfony2

    我想覆盖 FOSUserBundle 的一些路由 MyBundle Resources config routing security yml fos user security login path locale login defaul