Developing extensions/Access to in-process data
This article gives a short introduction on how to gain access to in-process data when using an extension, through a registered hook, or an additional parser function.
In general, the Help:SemanticData object when in an intermediary state (being processed in hooks or through the parser) is attached to MediaWiki's
ParserOutput to allow interdependent data exchange during the request.
To avoid loss of data or inconsistencies when accessing the Help:SemanticData object, it is recommended to use a
ParserData instance as gateway.
// Create in-memory ParserOutput transfer object $parserData = ApplicationFactory::getInstance()->newParserData( $parser->getTitle(), $parser->getOutput() );
// Access the SemanticData object $parserData->getSemanticData(); // Do something
An individual extension is required to finalize its update process by invoking (otherwise the extended
SemanticData instance will not be transferred to the
// Ensures that objects are pushed to the ParserOutput $parserData->pushSemanticDataToParserOutput();
This ensures that the
ParserOutput contains the most up-to-date Help:SemanticData object at the time when the
LinksUpdateConstructed hook is called which then will trigger the
Store::updateData together with the accumulated data.
ParserData::updateStore is not for public use therefore an extension is not expected to call this function.
- ParserFunctionFactory::newInterlanguageLinkParserFunctionDefinition contains an example on how to access
SemanticDataoutside of SMW-core
- #1202 SemanticData access from an extension (or how to add property values)