如何调试symfony2服务容器中配置的标签和服务?

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容器:

要调试服务容器,请使用以下控制台命令之一

当前版本(> 2.7)

显示所有注册的服务

app/console debug:container
Run Code Online (Sandbox Code Playgroud)

按标签排序的列表

app/console debug:container --tags
Run Code Online (Sandbox Code Playgroud)

过滤单个标签(即form.type)

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)


版本> 2.2至<2.7

显示所有注册的服务

app/console container:debug
Run Code Online (Sandbox Code Playgroud)

按标签排序的列表

app/console container:debug --tags
Run Code Online (Sandbox Code Playgroud)

过滤单个标签(即form.type)

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)


版本<2.2

要快速查找服务/标记(或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)