We want to be able to easily serialize entities in different formats (JSON-LD, XML). We also want to be able to keep route/controller logic separate from the serialization logic. And serialization handling should be modular so new serializations can be added without any hacking of core files.
Symfony has a Serializer component. A Serializer has two parts, the Normalizer, which transforms a custom data structure to simple objects and arrays, and an Encoder, which takes the result of normalization and serializes it out in the chosen format.
The Normalizer and Encoder can specify rules under which they should work. For example, a Normalizer can say "only use me if the object is an Entity and the requested format is jsonld". This means that you can simply pass the object and format into the Serializer, and it will choose the correct one to use. This should enable format agnostic routes and controllers, maintaining the separation between the REST module and the serialization that we want to see.
There are also Denormalizers and Decoders, which reverse the serialization process and would be used to handle POST and PUT.
Get the patch fromcleaned up and posted.
PASSED: [[SimpleTest]]: [MySQL] 42,547 pass(es).
PASSED: [[SimpleTest]]: [MySQL] 42,181 pass(es).
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1810472-add-serializer-component-5.patch. Unable to apply patch. See the log in the details link for more information.
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch core-1810472-add-serializer-component-1.patch. Unable to apply patch. See the log in the details link for more information.