-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update event_dispatcher.rst for consistency #7547
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
Improve event naming for example consistency with the what appends next.
components/event_dispatcher.rst
Outdated
@@ -135,7 +135,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid | |||
PHP callable to an event:: | |||
|
|||
$listener = new AcmeListener(); | |||
$dispatcher->addListener('acme.action', array($listener, 'onFooAction')); | |||
$dispatcher->addListener('foo.action', array($listener, 'onFooAction')); |
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.
What about renaming all of them 'acme.foo.action'?
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.
Due to naming convention described in the previous line of the doc I don't think that naming the event 'acme.foo.action'
is the better choice.
Maybe using 'acme_foo.action'
can be a prefered approach in regard of these naming convention :
- "Prefix names with a namespace followed by a dot"
- "End names with a verb"
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.
I guess here foo
is a placeholder for acme
and action
a placeholder for a verb, so maybe acme.foo
would be less confusing?
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.
According to the context I agree.
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.
By the way the example I given is perfectly valid, see https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/FOSUserEvents.php#L26 as an example :)
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.
FOS change password action have some sub-event possibilities, it makes more sense to nest these as you point here than the example show into the event dispatcher one.
To use 'acme.foo.action'
I consider using a pattern like '{vendor}.{context}.{action}'
. Do you agree with this before I update?
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.
I do :)
According to comment about the pull request symfony#7547, renaming the events acme.action to acme.foo.action
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.
👍
I'm sorry but I can't see why this change is needed. In the original article it was called |
In the current version the article is not consistent regarding the name of the event between the first one and the last one used in the "Connecting Listeners" section. First called About renaming it to |
@matthieu88160 now I see it!! I don't know why I didn't see it before 🙈 !! Thanks for fixing this. |
You'r welcome |
Good catch, thanks @matthieu88160. |
This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #7547). Discussion ---------- Update event_dispatcher.rst for consistency Improve event naming for example consistency with the what appends next. The event is initially named `foo.action` that break the consistency with the lines 164 and 169 of the document. Commits ------- 25c1cfc Update event_dispatcher.rst for consistency
Improve event naming for example consistency with the what appends next.
The event is initially named
foo.action
that break the consistency with the lines 164 and 169 of the document.