Symfony2 在服务创建之后但在控制器之前触发的事件
在创建自定义服务之后但在调用控制器操作之前是否有事件被触发?
Symfony2 中是否有所有事件的完整列表?
Is there an event that gets fired after my custom services are created but before the controller action is called?
And is there a full list of all events in Symfony2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DIC(依赖注入容器)的好处之一是,服务仅在您实际需要时才创建。这意味着大多数服务将从控制器内调用并创建。
为了回答您的问题,有一个在控制器之前触发的
kernel.request
事件,因此您可以使用它。One of the nice things about the DIC (Dependency Injection Container) is that the services are only created when you actually need them. This means that most services will be invoked and thus created from within the controller.
To answer your question, there is the
kernel.request
event that is fired before the controller, so you can use that.这里有一个事件列表,尽管我不确定它是否完整:
http://symfony.com/doc/current/book/internals.html#events
Here you have a list of events, though I'm not sure if it is complete:
http://symfony.com/doc/current/book/internals.html#events