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

Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

matthieu88160
Copy link
Contributor

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.

Improve event naming for example consistency with the what appends next.
@@ -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'));
Copy link
Contributor

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

Copy link
Contributor Author

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"

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

Copy link
Contributor Author

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?

Copy link
Contributor

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
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

👍

@javiereguiluz
Copy link
Member

I'm sorry but I can't see why this change is needed. In the original article it was called acme.foo.action? I can't find it.

@matthieu88160
Copy link
Contributor Author

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 acme.action it is renamed to foo.action into and after the comment.

About renaming it to acme.foo.action, take a look in the comments of the commit #7547 where @HeahDude offer to use a pattern as "{vendor}.{context}.{action}".

@javiereguiluz
Copy link
Member

@matthieu88160 now I see it!! I don't know why I didn't see it before 🙈 !! Thanks for fixing this.

@matthieu88160
Copy link
Contributor Author

You'r welcome

@xabbuh
Copy link
Member

xabbuh commented Mar 1, 2017

Good catch, thanks @matthieu88160.

xabbuh added a commit that referenced this pull request Mar 1, 2017
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
@xabbuh xabbuh closed this Mar 1, 2017
@xabbuh xabbuh mentioned this pull request Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants