-
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
base: main
Are you sure you want to change the base?
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).
$providers = iterator_to_array($providers); | ||
|
||
if (null !== $entityManager) { | ||
$providers[] = new DoctrineProvider($entityManager); |
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.
so we can't surcharge this provider and its static ? is there any way we could provide it with configuration so we can surcharge it ?
/** @var class-string<object>|'array' $source */ | ||
public string $source, | ||
/** @var class-string<object>|'array' $target */ |
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.
doesn't it makes a duplicate of the phpdoc we have just above ?
@@ -20,5 +20,5 @@ interface ProviderInterface | |||
* | |||
* @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.
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".
💯
"doctrine/collections": "^2.2", | ||
"doctrine/inflector": "^2.0", | ||
"doctrine/orm": "^3.3", |
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.
so this feature won't be tested with orm 2 (there are still a lot of them in the wild) ?
@@ -176,6 +179,12 @@ public static function create( | |||
$classDiscriminatorFromClassMetadata = new ClassDiscriminatorFromClassMetadata($classMetadataFactory); | |||
} | |||
|
|||
$providers = iterator_to_array($providers); |
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.
so all those providers will be instantiated here?
@@ -43,6 +43,7 @@ public function getConfigTreeBuilder(): TreeBuilder | |||
->end() | |||
->booleanNode('serializer_attributes')->defaultValue(interface_exists(SerializerInterface::class))->end() | |||
->booleanNode('api_platform')->defaultFalse()->end() | |||
->booleanNode('doctrine')->defaultFalse()->end() |
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.
couldn't this be autodiscovered? (ie: doctrine bundle is enabled)
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