Skip to content
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

Use event manager and registration compiler pass from Doctrine Bridge #80

Merged
merged 1 commit into from
Mar 1, 2012
Merged

Use event manager and registration compiler pass from Doctrine Bridge #80

merged 1 commit into from
Mar 1, 2012

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Feb 23, 2012

The problem was that doctrine-mongodb Connection services were never given an event manager, so they created a new event manager internally. The lack of event manager injection also meant that the compiler pass never attached listeners for doctrine-mongodb events (non-ODM events).

Given this limitation, I'm not sure how @jwage's Logging MongoDB Explains recipe could have worked, unless this problem does not exist for the bundle's Symfony 2.0-compatible version.

@stof
Copy link
Member

stof commented Feb 23, 2012

I'm wondering if you should go the same way than the DoctrineBundle uses: the event manager is created for a connection, and all different entity managers attached to the same connection share it. This is not a big issue IMO as I don't see a reason to have different EMs for the same connection.

Btw, as you are working on the listeners, I suggest again a refactoring of the DIC tags: DoctrineBundle was refactored during the beta releases to use only one tag for them (well, 2 because of subscribers) and the connection name is an optional attribute of the tag. I think you should refactor the bundle to go the same way for consistency

@jmikola
Copy link
Member Author

jmikola commented Feb 23, 2012

@stof: those are both good suggestions. I'll try that.

@jmikola
Copy link
Member Author

jmikola commented Feb 23, 2012

I opened symfony/symfony#3434. Will wait for that to be merged before I resume work on this PR and implement those changes.

This commit relies upon new Doctrine bridge classes in symfony/symfony#3434.

Previously, no event manager was given as a constructor argument for a Connection service, which lead to a new object being created internally. Since that event manager was not injected and wasn't registered with the service container, the compiler pass was unable to assign listeners on core doctrine-mongdb events.

This commit makes the event manager creation consistent with DoctrineBundle. Event managers now exist per connection, and document managers use the event manager of their connection.

BC break: the syntax for tags has changed. Previously, listeners were tagged as "doctrine.odm.mongodb.%s_event_listener", with the DM's configuration name as a placeholder. The "doctrine.common.event_listener" tag was also supported for global listeners. Listeners must now be tagged as "doctrine.odm.mongodb.event_listener". Tags may use a "connection" attribute to target a specific connection by name. Additionally, "priority" is also supported. This change applies to event subscribers as well.
@jmikola
Copy link
Member Author

jmikola commented Mar 1, 2012

@jwage: Any objections to merging this down?

symfony/symfony#3434 was merged and the corresponding change was also made in doctrine/DoctrineBundle#27.

I will submit a PR to update the documentation, but what should we do for reporting the BC break in this bundle? CHANGELOG.md, UPGRADE.md or something else?

@jwage
Copy link
Member

jwage commented Mar 1, 2012

I have it patched in our fork but hadn't sent the proper fix upstream yet. So ya, we can merge this just document it in CHANGELOG.md

👍

jwage added a commit that referenced this pull request Mar 1, 2012
Use event manager and registration compiler pass from Doctrine Bridge
@jwage jwage merged commit ffbc69c into doctrine:master Mar 1, 2012
jmikola added a commit to FriendsOfSymfony/FOSElasticaBundle that referenced this pull request Mar 23, 2012
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.

None yet

4 participants