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). More... | |
showMissingEntity (Title $title, IContextSource $context) | |
Handle the fact that a given page does not contain an Entity, even though it could. More... | |
getOnSaveValidators ( $forCreation, EntityId $entityId) | |
Get EntityValidators for on-save validation. More... | |
getValidationErrorLocalizer () | |
Error localizer for use together with getOnSaveValidators(). More... | |
makeEmptyContent () | |
makeEmptyEntity () | |
Returns an empty Entity object of the type supported by this handler. More... | |
makeEntityRedirectContent (EntityRedirect $redirect) | |
supportsCategories () | |
None of the Entity content models support categories. More... | |
generateHTMLOnEdit () | |
Do not render HTML on edit (T285987) More... | |
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. More... | |
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. More... | |
getTitleForId (EntityId $id) | |
Returns the appropriate page Title for the given EntityId. More... | |
getTitlesForIds (array $ids) | |
Returns the appropriate page Titles for the given EntityIds. More... | |
getEntityNamespace () | |
Returns the namespace that is to be used for this kind of entities. More... | |
getEntitySlotRole () | |
Returns the slot that is to be used for this kind of entities. More... | |
canBeUsedOn (Title $title) | |
isParserCacheSupported () | |
Returns true to indicate that the parser cache can be used for data items. More... | |
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. More... | |
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. More... | |
allowAutomaticIds () | |
Whether IDs can automatically be assigned to entities of the kind supported by this EntityHandler. More... | |
canCreateWithCustomId (EntityId $id) | |
Whether the given custom ID is valid for creating a new entity of the kind supported by this EntityHandler. More... | |
getFieldsForSearchIndex (SearchEngine $engine) | |
getDataForSearchIndex (WikiPage $page, ParserOutput $output, SearchEngine $engine) | |
getParserOutputForIndexing (WikiPage $page, ParserCache $cache=null) | |
Produce page output suitable for indexing. More... | |
Public Attributes | |
const | PARSER_VERSION = 3 |
Added to parser options for EntityContent. More... | |
Protected Member Functions | |
getDiffEngineClass () | |
newEntityContent (EntityHolder $entityHolder=null) | |
Protected Attributes | |
$fieldDefinitions | |
$contentCodec | |
$constraintProvider | |
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.
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 |
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).
Wikibase\Repo\Content\EntityHandler::getDataForSearchIndex | ( | WikiPage | $page, |
ParserOutput | $output, | ||
SearchEngine | $engine | ||
) |
WikiPage | $page | |
ParserOutput | $output | |
SearchEngine | $engine |
Wikibase\Repo\Content\EntityHandler::getDefaultFormat | ( | ) |
|
protected |
|
final |
Returns the namespace that is to be used for this kind of entities.
|
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\PropertyHandler, and Wikibase\Repo\Content\ItemHandler.
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 |
||
) |
Produce page output suitable for indexing.
Does not include HTML.
WikiPage | $page | |
ParserCache | null | $cache |
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\PropertyHandler, and Wikibase\Repo\Content\ItemHandler.
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().
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\PropertyHandler, and Wikibase\Repo\Content\ItemHandler.
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\PropertyHandler, and Wikibase\Repo\Content\ItemHandler.
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 |
MWException | Always. |
|
abstractprotected |
EntityHolder | null | $entityHolder |
Reimplemented in Wikibase\Repo\Content\PropertyHandler, and Wikibase\Repo\Content\ItemHandler.
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 |
|
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.