简体   繁体   English

Symfony2从Before过滤器发送RedirectResponse

[英]Symfony2 Sending RedirectResponse from Before Filter

I'm using Before Filter to detect what language is the application using (is it english or something else, for example) and then doing some stuff with it. 我正在使用Before Filter来检测应用程序使用的语言(例如,英语或其他语言),然后对其进行处理。 After I've done that stuff, I would like to send a RedirectResponse to another Symfony route like this... 完成这些工作后,我想将RedirectResponse发送到另一个类似这样的Symfony路由...

return new RedirectResponse(route_name)

but that doesn't work beacuse I'm not extending ContainerAware so the component that is getting the RedirectResponse object doesn't know what to do with it. 但这不起作用,因为我没有扩展ContainerAware,因此获取RedirectResponse对象的组件不知道如何处理它。

My question is, how to redirect from a before filter after I'm done with it? 我的问题是,完成后如何从before过滤器重定向?

Here are some question related answer: Symfony2 redirect for event listener? 以下是一些与问题相关的答案: Symfony2重定向事件监听器? Elnur Abdurrakhimov's answer or NHG's anwer would be helpful for you. Elnur Abdurrakhimov的回答或NHG的答案将对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM