Skip to content

[cookbook] add description of doctrine event subscriber #2301

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 3 commits into from
Mar 30, 2013
Merged

[cookbook] add description of doctrine event subscriber #2301

merged 3 commits into from
Mar 30, 2013

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Mar 12, 2013

this confused me quite a bit, so i thought i better document it: the doctrine event subscriber is simpler than the symfony event subscriber. if you return from doctrine an array mapping event names to method names, doctrine will register for "events" with the names of those methods.

…etween symfony and doctrine event subscriber
A doctrine event subscriber must implement the ``Doctrine\Common\EventSubscriber``
interface and an event method for each event it subscribes to.


Copy link
Member

Choose a reason for hiding this comment

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

You should add .. code-block::php before this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@dbu
Copy link
Contributor Author

dbu commented Mar 12, 2013

sorry, seem to be tired. fixed those (and the source of my copy-paste too)

@dbu
Copy link
Contributor Author

dbu commented Mar 14, 2013

@wouterj i fixed the styling problems. ok to merge?

@wouterj
Copy link
Member

wouterj commented Mar 14, 2013

@dbu yes, I think so. But @weaverryan is the only person who can merge, so you need to wait until he has some time to merge some PRs.

call for the events like the :ref:`Symfony event subscriber <event_dispatcher-using-event-subscribers>`
can do. Doctrine event subscribers must return a simple array of the event
names they subscribe to. Doctrine will then expect methods on the subscriber
with the names of the subscribed events, just as when using an event listener.
Copy link
Member

Choose a reason for hiding this comment

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

I think you should contribute this to the Doctrine Common documentation about the EventManager instead and link it from the Symfony doc. Let's improve the doc of the Doctrine project as well :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can try an update of the event listener doc in doctrine as well. but i still think that at least this tip belongs here rather than into the doctrine doc.
the doctrine doc already has an example of event listeners, but not event subscribers i think. i thought it does make sense to have the minimal examples here in the symfony doc too, to see how it works and then follow the link for details. how much of this cookbook entry would you want to remove?

Copy link
Member

Choose a reason for hiding this comment

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

well, the doctrine doc should have an example of subscribers IMO

@dbu
Copy link
Contributor Author

dbu commented Mar 19, 2013

i did a pull request on doctrine doc now doctrine/orm-documentation#155 and added more links from here to that doc. i think it is useful to have the concrete examples right here in this cookbook entry, even if its duplication.

@@ -152,4 +156,62 @@ specific type of entity (e.g. a ``Product`` entity but not a ``BlogPost``
entity), you should check for the class name of the entity in your method
(as shown above).

.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/events.html
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this link lead to a 404. i changed it (but git diff puts it at the very bottom of what i added here...)

@dbu
Copy link
Contributor Author

dbu commented Mar 19, 2013

created a doctrine PR on the right repository now: doctrine/orm#621

any other feedback on this?

weaverryan added a commit that referenced this pull request Mar 30, 2013
[cookbook] add description of doctrine event subscriber
@weaverryan weaverryan merged commit 508e2e6 into symfony:2.0 Mar 30, 2013
@weaverryan
Copy link
Member

Hey David!

Very nice addition! I've merged this in with only minor tweaks at sha: 6f191da.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants