Vũ *_*Anh 3 tags service events dependency-injection symfony
我正在编写一个处理AccessDeniedException的服务,我找到了一种方法来解决它使用Symfony2的AccessDeniedHandlerInterface
firewalls:
secured_area:
.....
access_denied_handler: kernel.listener.accessDenied.handler
Run Code Online (Sandbox Code Playgroud)
并在此处定义服务:
services:
kernel.listener.accessDenied.handler:
class: %kernel.listener.accessDenied.handler.class%
arguments: ["@service_container"]
tags:
- { name: 'kernel.event_listener', event: 'security.kernel_response', method: 'handle' }
Run Code Online (Sandbox Code Playgroud)
但我不知道在哪里可以找到这些属性的定义,例如event:'security.kernel_response'.'security.kernel_response'在哪里定义,哪里可以获取其他事件列表?
对于像'access_denied_handler'这样的其他处理程序,我如何确定相应服务的标签?
Nic*_*ich 12
调试Symfony容器:
要调试服务容器,请使用以下控制台命令之一
app/console debug:container
Run Code Online (Sandbox Code Playgroud)
app/console debug:container --tags
Run Code Online (Sandbox Code Playgroud)
app/console debug:container --tag=form.type
Run Code Online (Sandbox Code Playgroud)
app/console debug:container --show-private
Run Code Online (Sandbox Code Playgroud)
app/console container:debug
Run Code Online (Sandbox Code Playgroud)
app/console container:debug --tags
Run Code Online (Sandbox Code Playgroud)
app/console container:debug --tag=form.type
Run Code Online (Sandbox Code Playgroud)
app/console container:debug --show-private
Run Code Online (Sandbox Code Playgroud)
要快速查找服务/标记(或symfony2.<2上的标记服务),请使用grep(linux,osx)或findstr(windows),如下所示:
app/console container:debug | grep form
Run Code Online (Sandbox Code Playgroud)
要么
app/console container:debug | findstr form
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3375 次 |
最近记录: |