Wikibase
MediaWiki Wikibase extension
|
Base handler class for Entity content classes. More...
Public Member Functions | |
__construct ( $modelId, $unused, EntityContentDataCodec $contentCodec, EntityConstraintProvider $constraintProvider, ValidatorErrorLocalizer $errorLocalizer, EntityIdParser $entityIdParser, FieldDefinitions $fieldDefinitions, $legacyExportFormatDetector=null) | |
getLegacyExportFormatDetector () | |
Returns the callback used to determine whether a serialized blob needs to be re-serialized on export (or null of re-serialization is disabled). | |
showMissingEntity (Title $title, IContextSource $context) | |
Handle the fact that a given page does not contain an Entity, even though it could. | |
getOnSaveValidators ( $forCreation, EntityId $entityId) | |
Get EntityValidators for on-save validation. | |
getValidationErrorLocalizer () | |
Error localizer for use together with getOnSaveValidators(). | |
makeEmptyContent () | |
makeEmptyEntity () | |
Returns an empty Entity object of the type supported by this handler. | |
makeEntityRedirectContent (EntityRedirect $redirect) | |
supportsCategories () | |
None of the Entity content models support categories. | |
generateHTMLOnEdit () | |
Do not render HTML on edit (T285987) | |
getAutosummary (Content $oldContent=null, Content $newContent=null, $flags=0) | |
makeRedirectContent (Title $title, $text='') | |
exportTransform ( $blob, $format=null) | |
makeEntityContent (EntityHolder $entityHolder) | |
makeEntityId ( $id) | |
Parses the given ID string into an EntityId for the type of entity supported by this EntityHandler. | |
getDefaultFormat () | |
serializeContent (Content $content, $format=null) | |
unserializeContent ( $blob, $format=null) | |
getIdForTitle (Title $target) | |
Returns the ID of the entity contained by the page of the given title. | |
getTitleForId (EntityId $id) | |
Returns the appropriate page Title for the given EntityId. | |
getTitlesForIds (array $ids) | |
Returns the appropriate page Titles for the given EntityIds. | |
getEntityNamespace () | |
Returns the namespace that is to be used for this kind of entities. | |
getEntitySlotRole () | |
Returns the slot that is to be used for this kind of entities. | |
canBeUsedOn (Title $title) | |
isParserCacheSupported () | |
Returns true to indicate that the parser cache can be used for data items. | |
getPageViewLanguage (Title $title, Content $content=null) | |
getPageLanguage (Title $title, Content $content=null) | |
getSpecialPageForCreation () | |
Returns the name of the special page responsible for creating a page for this type of entity content. | |
getUndoContent (Content $latestContent, Content $newerContent, Content $olderContent, $undoIsLatest=false) | |
getEntityType () | |
Returns the entity type ID for the kind of entity managed by this EntityContent implementation. | |
allowAutomaticIds () | |
Whether IDs can automatically be assigned to entities of the kind supported by this EntityHandler. | |
canCreateWithCustomId (EntityId $id) | |
Whether the given custom ID is valid for creating a new entity of the kind supported by this EntityHandler. | |
getFieldsForSearchIndex (SearchEngine $engine) | |
getDataForSearchIndex (WikiPage $page, ParserOutput $parserOutput, SearchEngine $engine, RevisionRecord $revision=null) | |
getContentDataForSearchIndex (Content $content) | |
Extract fields data for the search index but only the fields related to the slot content. | |
getParserOutputForIndexing (WikiPage $page, ParserCache $cache=null, RevisionRecord $revision=null) | |
Produce page output suitable for indexing. | |
validateSave (Content $content, ValidationParams $validationParams) | |
Public Attributes | |
const | PARSER_VERSION = 3 |
Added to parser options for EntityContent. | |
Protected Member Functions | |
getDiffEngineClass () | |
getSlotDiffRendererWithOptions (IContextSource $context, $options=[]) | |
newEntityContent (EntityHolder $entityHolder=null) | |
fillParserOutput (Content $content, ContentParseParams $cpoParams, ParserOutput &$parserOutput) | |
getParserOutputForRedirect (EntityContent $content, bool $generateHtml) | |
getParserOutputFromEntityView (EntityContent $content, $revisionId, ParserOptions $options, $generateHtml=true) | |
Protected Attributes | |
$fieldDefinitions | |
$contentCodec | |
$constraintProvider | |
Private Member Functions | |
getValidUserLanguage (Language $language) | |
getEntityRevision (EntityContent $content, $revisionId=null) | |
applyEntityPageProperties (EntityContent $content, ParserOutput $parserOutput) | |
Registers any properties returned by getEntityPageProperties() in $parserOutput. | |
applyValidators (EntityContent $content, array $validators) | |
Apply the given validators. | |
Private Attributes | |
$errorLocalizer | |
$entityIdParser | |
$legacyExportFormatDetector | |
Base handler class for Entity content classes.
Wikibase\Repo\Content\EntityHandler::__construct | ( | $modelId, | |
$unused, | |||
EntityContentDataCodec | $contentCodec, | ||
EntityConstraintProvider | $constraintProvider, | ||
ValidatorErrorLocalizer | $errorLocalizer, | ||
EntityIdParser | $entityIdParser, | ||
FieldDefinitions | $fieldDefinitions, | ||
$legacyExportFormatDetector = null ) |
string | $modelId | |
mixed | $unused |
EntityContentDataCodec | $contentCodec | |
EntityConstraintProvider | $constraintProvider | |
ValidatorErrorLocalizer | $errorLocalizer | |
EntityIdParser | $entityIdParser | |
FieldDefinitions | $fieldDefinitions | |
callable | null | $legacyExportFormatDetector | Callback to determine whether a serialized blob needs to be re-serialized on export. The callback must take two parameters, the blob an the serialization format. It must return true if re-serialization is needed. False positives are acceptable, false negatives are not. |
Wikibase\Repo\Content\EntityHandler::allowAutomaticIds | ( | ) |
Whether IDs can automatically be assigned to entities of the kind supported by this EntityHandler.
|
private |
Registers any properties returned by getEntityPageProperties() in $parserOutput.
EntityContent | $content | |
ParserOutput | $parserOutput |
|
private |
Apply the given validators.
EntityContent | $content | |
EntityValidator[] | $validators |
Wikibase\Repo\Content\EntityHandler::canBeUsedOn | ( | Title | $title | ) |
This implementation returns true if and only if the given title's namespace is the same as the one returned by $this->getEntityNamespace().
Title | $title |
Wikibase\Repo\Content\EntityHandler::canCreateWithCustomId | ( | EntityId | $id | ) |
Whether the given custom ID is valid for creating a new entity of the kind supported by this EntityHandler.
Implementations are not required to check if an entity with the given ID already exists. If this method returns true, this means that an entity with the given ID could be created (or already existed) at the time the method was called. There is no guarantee that this continues to be true after the method call returned. Callers must be careful to handle race conditions.
EntityId | $id |
Wikibase\Repo\Content\EntityHandler::exportTransform | ( | $blob, | |
$format = null ) |
string | $blob | |
string | null | $format |
|
protected |
Wikibase\Repo\Content\EntityHandler::generateHTMLOnEdit | ( | ) |
Do not render HTML on edit (T285987)
Wikibase\Repo\Content\EntityHandler::getAutosummary | ( | Content | $oldContent = null, |
Content | $newContent = null, | ||
$flags = 0 ) |
We never want to use MediaWiki's autosummaries, used e.g. for new page creation. Override this to make sure they never overwrite our autosummaries (which look like the automatic summary prefixes with a section title, and so could be overwritten).
Content | null | $oldContent | |
Content | null | $newContent | |
int | $flags |
Wikibase\Repo\Content\EntityHandler::getContentDataForSearchIndex | ( | Content | $content | ) |
Extract fields data for the search index but only the fields related to the slot content.
Useful for EntityHandlers that may work on non-main slot contents.
@stable to override
Content | $content | the Content to extract search data from |
Wikibase\Repo\Content\EntityHandler::getDataForSearchIndex | ( | WikiPage | $page, |
ParserOutput | $parserOutput, | ||
SearchEngine | $engine, | ||
RevisionRecord | $revision = null ) |
Wikibase\Repo\Content\EntityHandler::getDefaultFormat | ( | ) |
|
protected |
|
final |
Returns the namespace that is to be used for this kind of entities.
|
private |
EntityContent | $content | |
int | null | $revisionId |
|
final |
Returns the slot that is to be used for this kind of entities.
|
abstract |
Returns the entity type ID for the kind of entity managed by this EntityContent implementation.
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
Wikibase\Repo\Content\EntityHandler::getFieldsForSearchIndex | ( | SearchEngine | $engine | ) |
SearchEngine | $engine |
Wikibase\Repo\Content\EntityHandler::getIdForTitle | ( | Title | $target | ) |
Returns the ID of the entity contained by the page of the given title.
Title | $target |
EntityIdParsingException |
Wikibase\Repo\Content\EntityHandler::getLegacyExportFormatDetector | ( | ) |
Returns the callback used to determine whether a serialized blob needs to be re-serialized on export (or null of re-serialization is disabled).
Wikibase\Repo\Content\EntityHandler::getOnSaveValidators | ( | $forCreation, | |
EntityId | $entityId ) |
Get EntityValidators for on-save validation.
bool | $forCreation | Whether the entity is created (true) or updated (false). |
Wikibase\Repo\Content\EntityHandler::getPageLanguage | ( | Title | $title, |
Content | $content = null ) |
This implementation unconditionally returns the wiki's content language. The PageContentLanguage hook is bypassed.
Title | $title | the page to determine the language for. |
Content | null | $content | the page's content, if you have it handy, to avoid reloading it. |
Wikibase\Repo\Content\EntityHandler::getPageViewLanguage | ( | Title | $title, |
Content | $content = null ) |
This implementation returns the user language, because entities get rendered in the user's language. The PageContentLanguage hook is bypassed.
Title | $title | the page to determine the language for. |
Content | null | $content | the page's content, if you have it handy, to avoid reloading it. |
Wikibase\Repo\Content\EntityHandler::getParserOutputForIndexing | ( | WikiPage | $page, |
ParserCache | $cache = null, | ||
RevisionRecord | $revision = null ) |
Produce page output suitable for indexing.
Does not include HTML.
|
protected |
EntityContent | $content | |
bool | $generateHtml |
|
protected |
EntityContent | $content | |
int | null | $revisionId | |
ParserOptions | $options | |
bool | $generateHtml |
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
|
protected |
Wikibase\Repo\Content\EntityHandler::getSpecialPageForCreation | ( | ) |
Returns the name of the special page responsible for creating a page for this type of entity content.
Returns null if there is no such special page.
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
Wikibase\Repo\Content\EntityHandler::getTitleForId | ( | EntityId | $id | ) |
Returns the appropriate page Title for the given EntityId.
EntityId | $id |
InvalidArgumentException | if $id refers to an entity of the wrong type. |
Wikibase\Repo\Content\EntityHandler::getTitlesForIds | ( | array | $ids | ) |
Returns the appropriate page Titles for the given EntityIds.
EntityId[] | $ids |
Wikibase\Repo\Content\EntityHandler::getUndoContent | ( | Content | $latestContent, |
Content | $newerContent, | ||
Content | $olderContent, | ||
$undoIsLatest = false ) |
Content | $latestContent | The current text |
Content | $newerContent | The revision to undo |
Content | $olderContent | Must be an earlier revision than $newer |
bool | $undoIsLatest | Set to true if $newer is from the current revision (since 1.32) |
Wikibase\Repo\Content\EntityHandler::getValidationErrorLocalizer | ( | ) |
Error localizer for use together with getOnSaveValidators().
|
private |
Wikibase\Repo\Content\EntityHandler::isParserCacheSupported | ( | ) |
Returns true to indicate that the parser cache can be used for data items.
Wikibase\Repo\Content\EntityHandler::makeEmptyContent | ( | ) |
|
abstract |
Returns an empty Entity object of the type supported by this handler.
This is intended to provide a baseline for diffing and related operations.
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
Wikibase\Repo\Content\EntityHandler::makeEntityContent | ( | EntityHolder | $entityHolder | ) |
EntityHolder | $entityHolder |
|
abstract |
Parses the given ID string into an EntityId for the type of entity supported by this EntityHandler.
If the string is not a valid serialization of the correct type of entity ID, an exception is thrown.
string | $id | String representation the entity ID |
InvalidArgumentException |
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
Wikibase\Repo\Content\EntityHandler::makeEntityRedirectContent | ( | EntityRedirect | $redirect | ) |
EntityRedirect | $redirect | Unused in this default implementation. |
Reimplemented in Wikibase\Repo\Content\ItemHandler.
Wikibase\Repo\Content\EntityHandler::makeRedirectContent | ( | Title | $title, |
$text = '' ) |
Title | $title | |
string | $text |
|
abstractprotected |
EntityHolder | null | $entityHolder |
Reimplemented in Wikibase\Repo\Content\ItemHandler, and Wikibase\Repo\Content\PropertyHandler.
Wikibase\Repo\Content\EntityHandler::serializeContent | ( | Content | $content, |
$format = null ) |
Content | $content | |
string | null | $format |
InvalidArgumentException | |
MWContentSerializationException |
Wikibase\Repo\Content\EntityHandler::showMissingEntity | ( | Title | $title, |
IContextSource | $context ) |
Handle the fact that a given page does not contain an Entity, even though it could.
Per default, this behaves similarly to Article::showMissingArticle: it shows a message to the user.
Title | $title | The title of the page that potentially could, but does not, contain an entity. |
IContextSource | $context | Context to use for reporting. In particular, output will be written to $context->getOutput(). |
Wikibase\Repo\Content\EntityHandler::supportsCategories | ( | ) |
None of the Entity content models support categories.
Wikibase\Repo\Content\EntityHandler::unserializeContent | ( | $blob, | |
$format = null ) |
string | $blob | |
string | null | $format |
MWContentSerializationException |
Wikibase\Repo\Content\EntityHandler::validateSave | ( | Content | $content, |
ValidationParams | $validationParams ) |
|
protected |
|
protected |
|
private |
|
private |
|
protected |
|
private |
const Wikibase\Repo\Content\EntityHandler::PARSER_VERSION = 3 |
Added to parser options for EntityContent.
Bump the version when making incompatible changes to parser output.