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

Expose ResolveTargetDocumentListener in configuration #197

Merged
merged 6 commits into from
May 16, 2014

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Sep 27, 2013

Supersedes #196, but depends on doctrine/mongodb 1.0.0-BETA10 tag.

@fixe
Copy link

fixe commented Dec 12, 2013

@kingcrunch: Is this ready to be used?

@kingcrunch
Copy link
Contributor

@fixe Uff ... Thats a while ago. If it doesn't conflict with alter changes there should be no problem.

@jmikola
Copy link
Member Author

jmikola commented Dec 14, 2013

It will work with the master branch. BETA10 just isn't tagged yet.

@ludofleury
Copy link
Contributor

I can't get it to work actually. I can't find where/how this tag "doctrine_mongodb.event_listener" is processed.

@jmikola
Copy link
Member Author

jmikola commented May 6, 2014

ODM BETA10 is tagged, so I'll try to get to this within the coming week.

@ludofleury
Copy link
Contributor

Thanks for the update

@kingcrunch
Copy link
Contributor

@jmikola 👍

@gquemener
Copy link
Contributor

We definitly need this patch :) Any issue I can work on to make it merged quickly?

if ($config['resolve_target_documents']) {
$def = $container->findDefinition('doctrine_mongodb.odm.listeners.resolve_target_document');
foreach ($config['resolve_target_documents'] as $name => $implementation) {
$def->addMethodCall('addResolveTargetDocument', array($name, $implementation, array()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just dropping an open question here: why not wrapping the $implementation inside a Symfony\Component\DependencyInjection\Parameter in case the container has this parameter?

This would allow to open some interesting extension point, especially when overriding a bundle document object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use case is to allow configuring resolved documents like so:

# app/config/config.yml
resolve_target_documents:
    Acme\Bundle\Model\BookInterface: acme.document.book.class

# services.yml
parameters:
    acme.document.book.class: Acme\Bundle\Document\Encyclopedia

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd require to move this service definition modification inside a compiler pass

Copy link
Contributor

Choose a reason for hiding this comment

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

And also provide the same behaviour for DoctrineBundle

Copy link
Member

Choose a reason for hiding this comment

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

@gquemener wrapping it in a Parameter instance forces it to be a parameter, which is likely to be wrong. Witht he current implementation, you can use parameters by using the %foo% syntax, which will be resolved in the method call argument

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, %foo% syntax should do it!

jmikola added a commit that referenced this pull request May 16, 2014
Expose ResolveTargetDocumentListener in configuration
@jmikola jmikola merged commit e022b83 into master May 16, 2014
@jmikola jmikola deleted the 3.0-ResolveTargetDocumentListener branch May 16, 2014 14:56
@gquemener
Copy link
Contributor

👍 Thanks

@jmikola
Copy link
Member Author

jmikola commented May 16, 2014

@gquemener: A new tag for the bundle is imminent; I'd just like to take care of #235 first.

@gquemener
Copy link
Contributor

@ludofleury In case you haven't figured that out for 5 months, the event_listener/subscriber tags are processed in a compiler pass defined in the Symfony Doctrine Brige (not in Doctrine Bundle).

I found it confusing too last week, but @stof showed me the way: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

@jmikola jmikola mentioned this pull request May 19, 2014
@jmikola jmikola modified the milestones: 3.0.0-BETA6, 3.0.0-BETA5 May 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants