-
Notifications
You must be signed in to change notification settings - Fork 19
Feature: Doctrine Provider #253
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
Conversation
dbb7b42
to
55436b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice to base mapping on Doctrine metadata factory.
I would like to see something like an attribute / context thing to say "this is a Doctrine entity but I don't want to use entity manager just map it normally".
Also I think it would be nice to have extension points, at the moment it is very rigid and we can't do much to extends it (mostly Doctrine provider in my opinion).
* @return object|array<mixed>|null the value to provide | ||
*/ | ||
public function provide(string $targetType, mixed $source, array $context): object|array|null; | ||
public function provide(string $targetType, mixed $source, array $context, /* mixed $id */): object|array|null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use context for this identifier ? Instead of modifying all the providers for only one provider ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the id is a major information that require its own variable. Futhermore, i think this id can be used by user provider so it's nice to have it here.
I really don't like putting that kind of information into the context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice feature 👍
WDYT of also supporting doctrine Mongo ODM?
since you're mainly relying on ClassMetadataFactory
which is an abstraction from doctrine/persistence
it should not require too much effort
I would like to see something like an attribute / context thing to say "this is a Doctrine entity but I don't want to use entity manager just map it normally".
💯
2771bbd
to
e187c8c
Compare
I updated the PR it should support the odm document manager, there is no configuration to tell which manager to use, but it's only an alias to set for the user in their service, don't want to go further, let's wait to se on how it's used |
I added the possibility to do :
Which will disable any provider discovered
Don't think it should be done in this PR, let's wait for usage before doing that |
I will merge this (but no release yet), will try this on a real project to see what if gives |
This allow automatically provide an entity from database instead of creating a new one, which will update values instead of generating a new entity
This is rather a first simple implementation, but it should work for the 90% use case