Service for serializing entity data.
More...
|
| __construct (EntityTitleStoreLookup $entityTitleStoreLookup, PropertyDataTypeLookup $propertyLookup, EntityDataFormatProvider $entityDataFormatProvider, SerializerFactory $serializerFactory, Serializer $entitySerializer, SiteLookup $siteLookup, RdfBuilderFactory $rdfBuilderFactory, EntityIdParser $entityIdParser) |
|
| getSerializedData (string $format, EntityRevision $entityRevision, RedirectRevision $followedRedirect=null, array $incomingRedirects=[], ?string $flavor=null) |
| Output entity data. More...
|
|
|
| rdfSerialize (EntityRevision $entityRevision, ?RedirectRevision $followedRedirect, array $incomingRedirects, RdfBuilder $rdfBuilder, ?string $flavor=null) |
|
| addIncomingRedirects (EntityId $targetId, ?EntityRedirect $followedRedirect, array $incomingRedirects, RdfBuilder $rdfBuilder) |
|
| newApiMain (string $format) |
| Returns an ApiMain module that acts as a context for the formatting and serialization. More...
|
|
| createApiSerializer (string $formatName) |
| Creates an API printer that can generate the given output format. More...
|
|
| getFlavor (?string $flavorName) |
| Get the producer setting for current data format. More...
|
|
| createRdfBuilder (string $format, ?string $flavorName) |
| Creates an Rdf Serializer that can generate the given output format. More...
|
|
| generateApiResult (EntityRevision $entityRevision, ApiFormatBase $printer) |
| Pushes the given $entity into the ApiResult held by the ApiMain module returned by newApiMain(). More...
|
|
| getApiSerialization (EntityRevision $entityRevision, ApiFormatBase $printer) |
| Serialize the entity data using the provided format. More...
|
|
Service for serializing entity data.
Note that we are using the API's serialization facility to ensure a consistent external representation of data entities. Using the ContentHandler to serialize the entity would expose internal implementation details.
For RDF output, this relies on the RdfBuilder class.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
-
Thomas Pellissier Tanon
-
Anja Jentzsch < anja..nosp@m.jent.nosp@m.zsch@.nosp@m.wiki.nosp@m.media.nosp@m..de >
◆ __construct()
◆ addIncomingRedirects()
Wikibase\Repo\LinkedData\EntityDataSerializationService::addIncomingRedirects |
( |
EntityId |
$targetId, |
|
|
?EntityRedirect |
$followedRedirect, |
|
|
array |
$incomingRedirects, |
|
|
RdfBuilder |
$rdfBuilder |
|
) |
| |
|
private |
- Parameters
-
EntityId | $targetId | |
EntityRedirect | null | $followedRedirect | The followed redirect, will be omitted from the output. |
EntityId[] | $incomingRedirects | |
RdfBuilder | $rdfBuilder | |
◆ createApiSerializer()
Wikibase\Repo\LinkedData\EntityDataSerializationService::createApiSerializer |
( |
string |
$formatName | ) |
|
|
private |
Creates an API printer that can generate the given output format.
- Parameters
-
string | $formatName | The desired serialization format, as a format name understood by ApiBase or RdfWriterFactory. |
- Returns
- ApiFormatBase|null A suitable result printer, or null if the given format is not supported by the API.
◆ createRdfBuilder()
Wikibase\Repo\LinkedData\EntityDataSerializationService::createRdfBuilder |
( |
string |
$format, |
|
|
?string |
$flavorName |
|
) |
| |
|
private |
Creates an Rdf Serializer that can generate the given output format.
- Parameters
-
string | $format | The desired serialization format, as a format name understood by ApiBase or RdfWriterFactory |
string | null | $flavorName | Flavor name (used for RDF output) |
- Exceptions
-
- Returns
- RdfBuilder|null A suitable result printer, or null if the given format is not supported.
◆ generateApiResult()
Wikibase\Repo\LinkedData\EntityDataSerializationService::generateApiResult |
( |
EntityRevision |
$entityRevision, |
|
|
ApiFormatBase |
$printer |
|
) |
| |
|
private |
Pushes the given $entity into the ApiResult held by the ApiMain module returned by newApiMain().
Calling $printer->execute() later will output this result, if $printer was generated from that same ApiMain module, as createApiPrinter() does.
- Parameters
-
EntityRevision | $entityRevision | The entity to convert ot an ApiResult |
ApiFormatBase | $printer | The output printer that will be used for serialization. Used to provide context for generating the ApiResult, and may also be manipulated to fine-tune the output. |
◆ getApiSerialization()
Wikibase\Repo\LinkedData\EntityDataSerializationService::getApiSerialization |
( |
EntityRevision |
$entityRevision, |
|
|
ApiFormatBase |
$printer |
|
) |
| |
|
private |
Serialize the entity data using the provided format.
Note that we are using the API's serialization facility to ensure a consistent external representation of data entities. Using the ContentHandler to serialize the entity would expose internal implementation details.
- Parameters
-
EntityRevision | $entityRevision | the entity to output. |
ApiFormatBase | $printer | the printer to use to generate the output |
- Returns
- string the serialized data
◆ getFlavor()
Wikibase\Repo\LinkedData\EntityDataSerializationService::getFlavor |
( |
?string |
$flavorName | ) |
|
|
private |
Get the producer setting for current data format.
- Exceptions
-
◆ getSerializedData()
Wikibase\Repo\LinkedData\EntityDataSerializationService::getSerializedData |
( |
string |
$format, |
|
|
EntityRevision |
$entityRevision, |
|
|
RedirectRevision |
$followedRedirect = null , |
|
|
array |
$incomingRedirects = [] , |
|
|
?string |
$flavor = null |
|
) |
| |
Output entity data.
- Parameters
-
string | $format | The name (mime type of file extension) of the format to use |
EntityRevision | $entityRevision | The entity |
RedirectRevision | null | $followedRedirect | The redirect that led to the entity, or null |
EntityId[] | $incomingRedirects | Incoming redirects to include in the output |
string | null | $flavor | The type of the output provided by serializer |
- Returns
- array tuple of ( $data, $contentType )
- Exceptions
-
UnknownFlavorException | |
MWException | |
◆ newApiMain()
Wikibase\Repo\LinkedData\EntityDataSerializationService::newApiMain |
( |
string |
$format | ) |
|
|
private |
Returns an ApiMain module that acts as a context for the formatting and serialization.
- Parameters
-
string | $format | The desired output format, as a format name that ApiBase understands. |
◆ rdfSerialize()
Wikibase\Repo\LinkedData\EntityDataSerializationService::rdfSerialize |
( |
EntityRevision |
$entityRevision, |
|
|
?RedirectRevision |
$followedRedirect, |
|
|
array |
$incomingRedirects, |
|
|
RdfBuilder |
$rdfBuilder, |
|
|
?string |
$flavor = null |
|
) |
| |
|
private |
- Parameters
-
EntityRevision | $entityRevision | |
RedirectRevision | null | $followedRedirect | a redirect leading to the entity for use in the output |
EntityId[] | $incomingRedirects | Incoming redirects to include in the output |
RdfBuilder | $rdfBuilder | |
string | null | $flavor | The type of the output provided by serializer |
- Returns
- string RDF
◆ $entityDataFormatProvider
Wikibase\Repo\LinkedData\EntityDataSerializationService::$entityDataFormatProvider |
|
private |
◆ $entityIdParser
Wikibase\Repo\LinkedData\EntityDataSerializationService::$entityIdParser |
|
private |
◆ $entitySerializer
Wikibase\Repo\LinkedData\EntityDataSerializationService::$entitySerializer |
|
private |
◆ $entityTitleStoreLookup
Wikibase\Repo\LinkedData\EntityDataSerializationService::$entityTitleStoreLookup |
|
private |
◆ $propertyLookup
Wikibase\Repo\LinkedData\EntityDataSerializationService::$propertyLookup |
|
private |
◆ $rdfBuilderFactory
Wikibase\Repo\LinkedData\EntityDataSerializationService::$rdfBuilderFactory |
|
private |
◆ $rdfWriterFactory
Wikibase\Repo\LinkedData\EntityDataSerializationService::$rdfWriterFactory |
|
private |
◆ $serializerFactory
Wikibase\Repo\LinkedData\EntityDataSerializationService::$serializerFactory |
|
private |
◆ $siteLookup
Wikibase\Repo\LinkedData\EntityDataSerializationService::$siteLookup |
|
private |
The documentation for this class was generated from the following file: