Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rewrite EventDispatcher introduction#6229

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@wouterj
Copy link
Member

QA
Doc fix?yes
New docs?no
Applies to2.3+
Fixed tickets-

The event dispatcher docs were a bit old. I discovered it talked about bundles (while it's the components section).

While reviewing the article, I've also removed some redundant things (creating special sub event classes was mentioned many times). I've also tried to reword things a bit and introduce new (more commonly used) concepts for events.

* Use only lowercase letters, numbers, dots (``.``) and underscores (``_``);
* Prefix names with a namespace followed by a dot (e.g. ``store.``);
* End names with a verb that indicates what action has been taken (e.g.
``order_placed``).
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's often more common to write event names in the past tense. An event notifies the system that something had happend. However, this is against the Symfony core (which kinda misuses events at the moment). I would like what you think about this.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. That's how I usually name my events too.

Choose a reason for hiding this comment

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

I like this list of proposals, but in my opinion it mixes mandatory things (characters which can be included in the event name) with recommendations. What about rewording it as follows?

Original:

The unique event name can be any string, but optionally follows a few simplenaming conventions:* Use only lowercase letters, numbers, dots (``.``) and underscores (``_``);* Prefix names with a namespace followed by a dot (e.g. ``store.``);* End names with a verb that indicates what action has been taken (e.g.  ``order_placed``).

Proposal:

The event name, which must be unique in the application, is a string whichcan only contain letters, numbers, dots (``.``) and underscores (``_``).Optionally, you can follow these naming conventions:* Use only lowercase letters;* Prefix names with a namespace followed by a dot (e.g. ``store.*``, ``user.*``);* End names with a verb that indicates what action has been taken (e.g.  ``order.placed``, ``user.created``).

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The string of the event name contain any character that can be added to a simple PHP string. So there is no mandatory thing in the list.

``Event`` object so that the listeners have the needed information. In such
case, a special subclass that has additional methods for retrieving and
overriding information can be passed when dispatching an event. For example,
the ``kernel.response`` uses a
Copy link
Member

Choose a reason for hiding this comment

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

[...] thekernel.response event uses [...]

@xabbuh
Copy link
Member

I left some minor comments, but overall I love your changes. 👍

have the same priority, they are executed in the order that they were
added to the dispatcher.
#. The event name (string) that this listener wants to listen to;
#. A PHP callable that will be notified when an event is thrown that it listens

Choose a reason for hiding this comment

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

I'd change this:

#. A PHP callable that will be notified when an event is thrown that it listensto;

by this:

#. A PHP callable that will be executed when the listened event is triggered;

@javiereguiluz
Copy link
Member

👍 I left some minor comments and suggestions, but overall this is great.

@wouterj you did a great job here. Thanks!

@wouterjwouterjforce-pushed thecomponent-eventdispatcher-remove-bundle branch fromdf71946 toe148cb4CompareFebruary 13, 2016 10:20
@wouterj
Copy link
MemberAuthor

Updated the PR

@xabbuh
Copy link
Member

👍

@xabbuh
Copy link
Member

Thank you@wouterj.

@xabbuhxabbuh merged commite148cb4 intosymfony:2.3Feb 15, 2016
xabbuh added a commit that referenced this pull requestFeb 15, 2016
This PR was merged into the 2.3 branch.Discussion----------Rewrite EventDispatcher introduction| Q | A| --- | ---| Doc fix? | yes| New docs? | no| Applies to | 2.3+| Fixed tickets | -The event dispatcher docs were a bit old. I discovered it talked about bundles (while it's the components section).While reviewing the article, I've also removed some redundant things (creating special sub event classes was mentioned many times). I've also tried to reword things a bit and introduce new (more commonly used) concepts for events.Commits-------e148cb4 Rewrite EventDispatcher introduction
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@wouterj@xabbuh@javiereguiluz

[8]ページ先頭

©2009-2025 Movatter.jp