https://bugzilla.wikimedia.org/show_bug.cgi?id=49952
Web browser: ---
Bug ID: 49952
Summary: SerializerFactory needs to be re-designed
Product: MediaWiki extensions
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: WikidataRepo
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Mobile Platform: ---
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l