-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Command] print registered event-listeners + event-subscribers #8234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed.
unittests are needed? |
$class = $containerBuilder->getDefinition($id)->getClass(); | ||
|
||
$refClass = new \ReflectionClass($class); | ||
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved out off loop, or even hardcoded, as it's not used anymore.
$table = $this->getHelperSet()->get('table'); | ||
$table | ||
->setHeaders(array('Class', 'Event')) | ||
->setLayout(TableHelper::LAYOUT_BORDERLESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using default layout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table should look like the "container:debug" command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it does not, does it?
I opened #8292 to fix that.
IMHO, you should add a big warning: You can display only "configured" listener. i.e.: You can not display listener created during the run-time. I know this is obvious, but not for every body. |
{ | ||
$this | ||
->setName('event_dispatcher:debug') | ||
->addArgument('event', InputArgument::OPTIONAL, 'Show listeners for a event', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for an event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can leave the '' last argument as it is defaulting to null also
closing in favor of #10388 |
…isplay registered listeners (matthieuauger) This PR was merged into the 2.6-dev branch. Discussion ---------- [FrameworkBundle] [Command] Event Dispatcher Debug - Display registered listeners | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT ------------------------------------------ [Update] The PR has been updated in order to comply with @stof comments. Current status : - [x] New event dispatcher Descriptor - [x] Manage all callables - [x] Unit tests - [x] Text description - [x] XML description - [x] Json description - [x] Markdown description ----------------------------------------- Hi. In some big applications with lots of events, it's often hard to debug which classes listen to which events, and what is the order of theses listeners. This PR allows to run - *event-dispatcher:debug* which displays all configured listeners + the events they listen to  - *event-dispatcher:debug* **event** which displays configured listeners for this specific event (order by priority desc)  The output is similar to *container:debug* command and is available in all supported formats (txt, xml, json and markdown). I found another PR with same goal (#8234), but the approach looks too complicated to me plus I think we should fetch the listeners directly with the event_dispatcher. Commits ------- ce53c8a [FrameworkBundle] Add Event Dispatcher debug command
New console-command for the event-dispatcher. The command prints a table like the
container:debug
command with all registered events and their event-listeners.The list is sorted by events.
There is an additional argument
event
. If this parameter is set, the command prints the listener for the event.