-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Use Doctrine metadata #247
Comments
The latest version is able to guess the metadata based on the Doctrine mapping if you register the driver: https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/Metadata/Driver/DoctrineTypeDriver.php |
Great thanks! When you say latest version, you mean stable (0.15.0) or master? And how do we use this driver? I can't find anything about it in the SerializerBuilder (at least in stable)? |
it is available in 0.15.0. Hmm, the SerializerBuilder indeed does not support registering the driver |
If I create a PR adding |
or |
This is related to #232 - which is basically about that.
|
OK should I close this one then? |
No, let's keep this open. It already has some more details. |
Any ideas, when this functionality will be available? Thanks |
👍 |
* commit 'c8a171357ca92b6706e395c757f334902d430ea9': fixes a regression moves driver creation to dedicated class (closes schmittjoh#247) Changed some constraint to allow latest versions Add support for XML namespace on the XML root element Added test for leading backslash in front of class name to TypeParserTest tests for accessor (public_method) Allow to fetch data from has*() with public_method Improve yaml documentacion Fix schmittjoh#100
FYI, here is how I managed to do it: $builder = SerializerBuilder::create();
$builder->addMetadataDir(...)
->addMetadataDir(..., 'User\Domain');
$builder->setMetadataDriverFactory(new CallbackDriverFactory(function ($metadataDirs, Reader $reader) use ($container) {
$driver = new DriverChain([
new YamlDriver(new FileLocator($metadataDirs)),
new AnnotationDriver($reader),
]);
/** @var ManagerRegistry $em */
$registry = $container->get(ManagerRegistry::class);
return new DoctrineTypeDriver($driver, $registry);
}));
return $builder->build(); I think it's too bad it forces us to use the But anyway it seems to work, I have done only small tests for now. Thank you for implementing it @schmittjoh. |
I don't think we get around the registry requirement. A simple registry implementation is here: |
Is there a way to avoid writing the same metadata twice: once for Doctrine, once for the Serializer?
I am thinking mainly about the property types. I am currently using YAML mapping for Doctrine, and YAML mapping to for the serializer.
The text was updated successfully, but these errors were encountered: