symfony2 中的 Before-Action 方法 [英] Before-Action method in symfony2
问题描述
我想在我的 symfony2 应用程序中编写一个通用代码,该代码应该在调用任何操作方法之前执行.我该怎么做?
I want to write a common code in my symfony2 application that should be executed before calling any action-method. How Can I do it?
在登录成功时,我正在会话中存储一些数据.如果用户稍后使用记住我的功能访问应用程序.我想恢复会话数据.常见的代码是恢复会话数据.
At the time of login-success, I am storing some data in session. If the user visit the application later with remember-me functionality. I want to restore the session data. The common code is to restore the session data.
推荐答案
文档中提供了设置过滤器之前和之后的方法.请请参阅链接 http://symfony.com/doc/2.0/cookbook/event_dispatcher/before_after_filters.html
The method to setup before and after Filters are available in the documentation. Please see the link http://symfony.com/doc/2.0/cookbook/event_dispatcher/before_after_filters.html
这篇关于symfony2 中的 Before-Action 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!