-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Configured order of custom handlers is ignored #174
Comments
The code looks correct to me; Could you give more information what did not work as expected? |
When I have a look at the data in the debugger, I find my configuration in PS: Many thanks for your great bundles! I'm just implementing a kind of remote doctrine over REST using the serializer and aop bundle with only a few 100 lines of code. |
|
Well that's what I tried. I put this jms_serializer:
handlers:
my_custom_handler: true
object_based: false
datetime:
format: "Y-m-dTH:i:s"
default_timezone: "UTC"
array_collection: true
form_error: true
constraint_violation: true into Isn't this the way to go? |
Yes that should work. Could you dump the content of |
Here it is.
As you can see, the custom handler shows up as the second last entry. As far as I understand, this is because it relies on the order |
I see the problem now. This actually needs to be fixed in symfony itself (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/Definition/ArrayNode.php#L268). Maybe you could open a ticket there? For the time being, I think it should work if you just make sure that the bundle which is providing your handler is registered before this bundle, and we also need to change the documentation. If you like you could send a PR for this, otherwise I will do it at some point, just keep the issue open. |
Thanks! Got it. Opened an issue: symfony/symfony#5528 |
Thanks, closing this here. |
The documentation at http://jmsyst.com/de/bundles/JMSSerializerBundle/master/cookbook/custom_handlers sais: The order in which the handlers are listed in the “handlers” section defines in which they are called while processing.
I'm not 100% sure what this means. My understanding is that I can put something like this
into app/config/config.yml which should make sure that my_custom_handler is always called first.
But looking at JMSSerializerExtension::load line 77ff makes clear that this configuration is ignored. The order depends on the order the configureSerializerExtension methods are called on the bundles.
My sugestion would be to change the above code to obey what is configured in the handler section. A question that arises by implenting it that way is: What should happen to handlers which are not listed there. I think they should be ignored (and the developer should be warned, but I don't know how to do that).
The text was updated successfully, but these errors were encountered: