Last modified: 2013-11-12 16:31:14 UTC
The SerializerFactory needs a redesign. As it is now, (some of the) serializers require specialized option objects, so the caller has to know about them in advance, which defies the purpose of the factory. Serialization needs to be able to work recursively, so I'd suggest to use the approach we discussed for serializers during the Q/A workshop: Have a top level serialization service that knows serialization handlers for several kinds of objects. The serialization handlers get the serialization service passed into their serialize() method along with the object to serialize, so they can use the serialization service to opaquely serialize any sub-structures: SerializationService { function __construct( Serializer[] ); function serialize( object $object ); } Serializer { function serialize( object $object, SerializationService $service ); } Note that the name "serializer" should be reconsidered - our current serializers do not serialize, but convert to native data structures (nested arrays) which are later encoded as JSON (which is the actual serialization). Perhaps the above could be renamed/generalized into ConverterService + Conversion, with the same basic interfaces (and perhaps even code) used to convert to and from native representation, generate HTML, etc.
Change 89850 had a related patch set uploaded by Daniel Kinzler: Consolidate SerializationOptions. https://gerrit.wikimedia.org/r/89850
Change 89850 merged by jenkins-bot: [bug 49952] Consolidate SerializationOptions. https://gerrit.wikimedia.org/r/89850
patch is merged