doctrine / DoctrineMongoDBBundle

Integrates Doctrine MongoDB ODM with Symfony
http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html
MIT License
377 stars 229 forks source link

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

Closed ivanQuantox closed 1 year ago

ivanQuantox commented 1 year ago

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

HypeMC commented 1 year ago

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 }
malarzm commented 1 year ago

@HypeMC thanks for the PR and code snippet! I was just finishing looking at https://github.com/symfony/symfony/pull/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

ivanQuantox commented 1 year ago

@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)

HypeMC commented 1 year ago

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).

ivanQuantox commented 1 year ago

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

HypeMC commented 1 year ago

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.

ivanQuantox commented 1 year ago

Thanks for the feedback! :)