Wikibase
MediaWiki Wikibase extension
|
A codec for use by EntityContent resp EntityHandler subclasses for the serialization and deserialization of EntityContent objects. More...
Public Member Functions | |
__construct (EntityIdParser $entityIdParser, Serializer $entitySerializer, Deserializer $entityDeserializer, $maxBlobSize=0) | |
getSupportedFormats () | |
Returns the supported serialization formats as a list of strings. | |
getDefaultFormat () | |
encodeEntity (EntityDocument $entity, $format) | |
Encodes an Entity into a blob for storage. | |
encodeRedirect (EntityRedirect $redirect, $format) | |
Encodes an EntityRedirect into a blob for storage. | |
decodeEntity ( $blob, $format) | |
Decodes a blob loaded from storage into an Entity. | |
decodeRedirect ( $blob, $format) | |
Decodes a blob loaded from storage into an EntityRedirect. | |
Private Member Functions | |
sanitizeFormat ( $format) | |
Returns a sanitized version of $format. | |
encodeEntityContentData (array $data, $format) | |
Encodes the given array structure as a blob using the given serialization format. | |
decodeEntityContentData ( $blob, $format) | |
Decodes the given blob into an array structure representing an EntityContent object. | |
extractEntityId (array $data, $key) | |
Private Attributes | |
$entityIdParser | |
$entitySerializer | |
$entityDeserializer | |
$maxBlobSize | |
A codec for use by EntityContent resp EntityHandler subclasses for the serialization and deserialization of EntityContent objects.
This class only deals with the representation of EntityContent as an array structure, not with EntityContent objects. It is needed to allow client side code to deserialize entity content data without the need to depend on EntityContent objects, which are only available on the repo.
Wikibase\Lib\Store\EntityContentDataCodec::__construct | ( | EntityIdParser | $entityIdParser, |
Serializer | $entitySerializer, | ||
Deserializer | $entityDeserializer, | ||
$maxBlobSize = 0 |
|||
) |
EntityIdParser | $entityIdParser | |
Serializer | $entitySerializer | A service capable of serializing EntityDocument objects. |
Deserializer | $entityDeserializer | A service capable of deserializing EntityDocument objects. |
int | $maxBlobSize | The maximum size of a blob to allow during serialization/deserialization, in bytes. Set to 0 to disable the check. |
Wikibase\Lib\Store\EntityContentDataCodec::decodeEntity | ( | $blob, | |
$format | |||
) |
Decodes a blob loaded from storage into an Entity.
string | $blob | |
string | null | $format | The serialization format of the data blob. One of the CONTENT_FORMAT_... constants or null for the default. |
InvalidArgumentException | If the format is not supported. |
MWContentSerializationException |
|
private |
Decodes the given blob into an array structure representing an EntityContent object.
string | $blob | The data blob to deserialize |
string | null | $format | The serialization format of $blob |
InvalidArgumentException | If the format is not supported. |
MWContentSerializationException |
Wikibase\Lib\Store\EntityContentDataCodec::decodeRedirect | ( | $blob, | |
$format | |||
) |
Decodes a blob loaded from storage into an EntityRedirect.
string | $blob | |
string | null | $format | The serialization format of the data blob. One of the CONTENT_FORMAT_... constants or null for the default. |
InvalidArgumentException | If the format is not supported. |
MWContentSerializationException | If the array could not be decoded. |
Wikibase\Lib\Store\EntityContentDataCodec::encodeEntity | ( | EntityDocument | $entity, |
$format | |||
) |
Encodes an Entity into a blob for storage.
EntityDocument | $entity | |
string | null | $format | The desired serialization format. One of the CONTENT_FORMAT_... constants or null for the default. |
MWContentSerializationException | |
EntityContentTooBigException |
|
private |
Encodes the given array structure as a blob using the given serialization format.
array | $data | A nested data array representing (part of) an EntityContent object. |
string | null | $format | The desired serialization format. |
InvalidArgumentException | If the format is not supported. |
MWContentSerializationException | If the array could not be encoded. |
Wikibase\Lib\Store\EntityContentDataCodec::encodeRedirect | ( | EntityRedirect | $redirect, |
$format | |||
) |
Encodes an EntityRedirect into a blob for storage.
EntityRedirect | $redirect | |
string | null | $format | The desired serialization format. One of the CONTENT_FORMAT_... constants or null for the default. |
InvalidArgumentException | If the format is not supported. |
MWContentSerializationException |
|
private |
array | $data | An array representation of an EntityContent object. |
string | $key | The key in $data that contains the serialized ID. |
MWContentSerializationException |
Wikibase\Lib\Store\EntityContentDataCodec::getDefaultFormat | ( | ) |
Wikibase\Lib\Store\EntityContentDataCodec::getSupportedFormats | ( | ) |
Returns the supported serialization formats as a list of strings.
|
private |
Returns a sanitized version of $format.
string | null | $format | The requested format. If null, getDefaultFormat() will be consulted. |
|
private |
|
private |
|
private |
|
private |