我正在编写一个服务来处理 AccessDeniedException 并且我找到了解决它的方法 Using Symfony2's AccessDeniedHandlerInterface
firewalls:
secured_area:
.....
access_denied_handler: kernel.listener.accessDenied.handler
并在这里定义服务:
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' }
但我不知道在哪里可以找到这些属性的定义,例如 事件:“security.kernel_response” . 'security.kernel_response' 是在哪里定义的,我在哪里可以获得其他事件的列表?
对于“access_denied_handler”等其他处理程序,我如何确定相应服务的标签?
最佳答案
调试 Symfony 容器:
要调试服务容器,请使用以下控制台命令之一
当前版本 (> 2.7)
显示所有注册服务
app/console debug:container
按标签排序的列表
app/console debug:container --tags
由单个标签过滤(即 form.type )
app/console debug:container --tag=form.type
并包括私有(private)服务
app/console debug:container --show-private
版本 > 2.2 到 < 2.7
显示所有注册服务
app/console container:debug
按标签排序的列表
app/console container:debug --tags
由单个标签过滤(即 form.type )
app/console container:debug --tag=form.type
并包括私有(private)服务
app/console container:debug --show-private
版本 < 2.2
要快速查找服务/标签(或 symfony2.<2 上的标签服务),请使用 grep ( linux, osx ) 或 findstr ( windows ) 用这样的管道:
app/console container:debug | grep form
或者
app/console container:debug | findstr form
关于events - 如何调试 symfony2 服务容器中配置的标签和服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16688519/