How to debug tags and services configured in the s

2019-04-12 17:20发布

I am writing a service to handle AccessDeniedException and I found a way to solve it from Using Symfony2's AccessDeniedHandlerInterface

 firewalls:
         secured_area:
         .....
            access_denied_handler: kernel.listener.accessDenied.handler

And define the service here:

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' }

But I dont know where I can find the definitions of these attributes for example event: 'security.kernel_response' . Where is the 'security.kernel_response' defined and where I can get the list of other events?

And for other handlers like 'access_denied_handler', how can I determine the tags for the corresponding services?

1条回答
SAY GOODBYE
2楼-- · 2019-04-12 17:40

Debugging the Symfony container:

To debug the service container please use one of the following console commands

Current versions (> 2.7)

Show all registered services

app/console debug:container

List ordered by tags

app/console debug:container --tags

Filtered by a single tag ( i.e. form.type )

app/console debug:container --tag=form.type

and to include private services

app/console debug:container --show-private


Versions > 2.2 to < 2.7

Show all registered services

app/console container:debug

List ordered by tags

app/console container:debug --tags

Filtered by a single tag ( i.e. form.type )

app/console container:debug --tag=form.type

and to include private services

app/console container:debug --show-private


Versions < 2.2

To quickly find a service / tag (or tagged services on symfony2.<2) use grep ( linux, osx ) or findstr ( windows ) with a pipe like this:

app/console container:debug | grep form

or

app/console container:debug | findstr form
查看更多
登录 后发表回答