Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle][EventDispatcher] Add priorities to the debug:event-dispatcher command #14563

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

Merged
merged 1 commit into from
May 6, 2015

Conversation

Seldaek
Copy link
Member

@Seldaek Seldaek commented May 5, 2015

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR TODO

I find it helps to figure out which priority is needed to override another event listener without digging in the sources.

@Seldaek Seldaek added FrameworkBundle EventDispatcher DX DX = Developer eXperience (anything that improves the experience of using Symfony) labels May 5, 2015
@dupuchba
Copy link
Contributor

dupuchba commented May 5, 2015

That's a really good thing ! (ping @matthieuauger) I will look at it tomorrow @Seldaek , thx

@fabpot
Copy link
Member

fabpot commented May 5, 2015

👍

1 similar comment
@stloyd
Copy link
Contributor

stloyd commented May 5, 2015

👍

+-------+-------------------+
+-------+-------------------+----------+
| Order | Callable | Priority |
+-------+-------------------+----------+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just replace the "Order" column with priority don't you think ? The "Order" column was just there because it was impossible to get priorities in dispatcher !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I wasn't quite sure why the Order column was there, maybe for people who can't count :P If you'd like to send a PR to remove it from the TextDescriptor that sounds good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep both , the order is useful when events have the same priority.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command already list the events by order so the information is still available. But finally I think it's more developer friendly to keep it, you don't have to know how Symfony manage order internally 👍

@stof
Copy link
Member

stof commented May 6, 2015

👍

@fabpot
Copy link
Member

fabpot commented May 6, 2015

Thank you @Seldaek.

@fabpot fabpot merged commit 952929c into symfony:2.8 May 6, 2015
fabpot added a commit that referenced this pull request May 6, 2015
…he debug:event-dispatcher command (Seldaek)

This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle][EventDispatcher] Add priorities to the debug:event-dispatcher command

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | TODO

I find it helps to figure out which priority is needed to override another event listener without digging in the sources.

Commits
-------

952929c [FrameworkBundle][EventDispatcher] Add priorities to the debug:event-dispatcher command
{
if (true === $withPriorities) {
return $eventName ? $this->listeners[$eventName] : array_filter($this->listeners);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is broken when there is no listener for $eventName

fabpot added a commit that referenced this pull request Oct 12, 2015
…iority() (fabpot)

This PR was merged into the 2.8 branch.

Discussion
----------

[EventDispatcher] added EventDispatcher::getListenerPriority()

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14563, #15825
| License       | MIT
| Doc PR        | n/a

In #14563, we added a way to get the priorities of listeners, but as noted by @Tobion in #15825, the implementation is sub-optimal because of two main reasons: the change is not part of the interface but more importantly, the added boolean changes the return value of `getListeners()`.

This PR reverts most of #14563 to add a `getListenerPriority()` method. This method is quite slow, but as it should only be used for debugging purposes (on the CLI or the WDT), I think it's not really a problem.

In 3.0, this method should probably be added to `EventDispatcherInterface`.

ping @Tobion

Commits
-------

068e955 [EventDispatcher] added EventDispatcher::getListenerPriority()
@fabpot fabpot mentioned this pull request Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) EventDispatcher FrameworkBundle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants