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

标签 events symfony service dependency-injection tags

我正在编写一个服务来处理 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/

相关文章:

c++ - 在 BeforeNavigate2 事件中枚举表单

c# - 为什么 "new"运算符使用 -= 分离事件处理程序?

docker - Selenium 与 behat : Unable to find provider for session

Android Google Play 服务生命周期

windows - 关于 WCF 服务总线

asp.net - OnTextChanged 事件未触发

java - 如何对 FXML 中的不同按钮使用相同的事件

php - 脚本 php artisan 优化处理返回错误代码 1 的 post-update-cmd 事件

rest - Symfony2 - 如何在测试 REST API 时获取自定义 header

java - 蓝牙适配器服务仍为空