doctrine/DoctrineMongoDBBundle

Move and extend Symfony 6.2 #[MapEntity] to support ODM as well

ivanQuantox opened this issue ยท 7 comments

I have created an issue on Symfony git repo and I've been told to open issue here.

As @fabpot and @shkabo suggested here #[MapEntity] can be moved from Symfony to here and add #[MapDocument] to support both ORM/ODM.

For more details take a look here: issue

Actually, despite the name, the EntityValueResolver & #[MapEntity] attribute work with MongoDB documents as well, it's just missing the wiring. I've created a PR, but you can add it manually as well, eg:

doctrine_mongodb.odm.entity_value_resolver.expression_language:
    class: Symfony\Component\ExpressionLanguage\ExpressionLanguage

doctrine_mongodb.odm.entity_value_resolve:
    class: Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver
    arguments:
        - '@doctrine_mongodb'
        - '@doctrine_mongodb.odm.entity_value_resolver.expression_language'
    tags:
        - { name: controller.argument_value_resolver, priority: 110 }

@HypeMC thanks for the PR and code snippet! I was just finishing looking at symfony/symfony#43854 to see if the code still works in an agnostic way to have ODM covered, and your comment confirms what I hoped for :) Please give me some time to think how to best support deprecation of old ParamConverter going forward

@HypeMC Thanks for the PR, can mapping be used instead of expression language? Since i have CustomFinders which are being used

edit:
With mapping i could say 'finder' => 'CustomFinder' (if MapEntity now works same as ParamConverter did)

Hi, honestly, I'm not sure what you mean by "finder", as far as I can tell, no such option exists. I might be mistaking, but it seems to me that you have a custom param converter. If that is the case, then the EntityValueResolver & #[MapEntity] are of no use to you, what you need is a custom value resolver (& possibly attribute).

Hey @HypeMC, sorry for quite late reply, whats the progress with your PR? Any info when will it be available to merge?

Hi, the PR is ready and even approved. As far as when it'll be merged, I don't have that information, you'll have to ask the maintainers. I'm guessing they have some release schedule.

Thanks for the feedback! :)