-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Make possible to set ArrayCollectionHandler classes from outside #1131
Comments
What do you mean by "hardcoded" ? If you want to add extra extensions you can do this: $serializerBuilder = SerializerBuilder::create();
$serializerBuilder->addMetadataDir('metadata dir', 'TestNs');
$serializerBuilder->configureHandlers(function (HandlerRegistryInterface $handler) use ($serializerBuilder) {
// default handlers
$serializerBuilder->addDefaultHandlers();
// your handlers
$handler->registerSubscribingHandler(new YourhandlerHere());
}); |
@goetas sorry I mean this classes are hardcoded: serializer/src/Handler/ArrayCollectionHandler.php Lines 34 to 40 in 4c1e429
And would think about something like this in the JMS SerializerBundle to add your custom ArrayCollectionClasses:
|
you can easily register more handlers <service id="app.my_handler" class="JMS\Serializer\Handler\ArrayCollectionHandler">
<tag name="jms_serializer.handler" type="CustomClass"
direction="serialization" format="json"
method="serializeCollection" />
<tag name="jms_serializer.handler" type="CustomClass"
direction="deserialization" format="json"
method="deserializeCollection" />
</service> This will register ArrayCollectionHandler for the CustomClass type |
Oh didn't thought about that solution. Great! Thank you! |
The ArrayCollectionHandler classes are currently hardcoded. It would be good if the ArrayCollectionHandler get its classes from outside and so in the jms serializer bundle I could use PrependExtension in my bundle config to add a class to the ArrayCollectionHandler.
Expected Result
Actual Result
The text was updated successfully, but these errors were encountered: