Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Content\EntityContentFactory Class Reference

Factory for EntityContent objects. More...

+ Inheritance diagram for Wikibase\Repo\Content\EntityContentFactory:
+ Collaboration diagram for Wikibase\Repo\Content\EntityContentFactory:

Public Member Functions

 __construct (array $entityContentModels, array $entityHandlerFactoryCallbacks, EntitySourceDefinitions $entitySourceDefinitions, EntitySource $localEntitySource, InterwikiLookup $interwikiLookup=null)
 
 isEntityContentModel (string $contentModel)
 Determines whether the given content model is designated to hold some kind of Wikibase entity. More...
 
 getEntityContentModels ()
 
 getEntityTypes ()
 
 getTitleForId (EntityId $id)
 Returns the Title object for the item with provided id. More...
 
 getTitlesForIds (array $ids)
 Returns Title objects for the entities with provided ids. More...
 
 getEntityIdForTitle (Title $title)
 Returns the ID of the entity associated with the given page title. More...
 
 getEntityIds (array $titles)
 
 getNamespaceForType (string $entityType)
 Determines what namespace is suitable for the given type of entities. More...
 
 getSlotRoleForType (string $entityType)
 Determines which slot is used to store a given type of entities. More...
 
 getContentHandlerForType (string $entityType)
 Returns the EntityHandler for the given entity type. More...
 
 getEntityHandlerForContentModel (string $contentModel)
 Returns the EntityHandler for the given model id. More...
 
 getContentModelForType (string $entityType)
 Determines what content model is suitable for the given type of entities. More...
 
 newFromEntity (EntityDocument $entity)
 Constructs a new EntityContent from an Entity. More...
 
 newFromRedirect (EntityRedirect $redirect)
 Constructs a new EntityContent from an EntityRedirect, or null if the respective kind of entity does not support redirects. More...
 

Private Member Functions

 getTitleForFederatedId (EntityId $id)
 If the EntityId is federated, return a Title for it. More...
 
 entityNotFromLocalEntitySource (EntityId $id)
 

Private Attributes

 $entityContentModels
 
 $entityHandlerFactoryCallbacks
 
 $interwikiLookup
 
 $entityHandlers = []
 
 $entitySourceDefinitions
 
 $localEntitySource
 
 $titleForIdCache
 

Detailed Description

Factory for EntityContent objects.

Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Daniel Kinzler
Bene* < benes.nosp@m.tar..nosp@m.wikim.nosp@m.edia.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Content\EntityContentFactory::__construct ( array  $entityContentModels,
array  $entityHandlerFactoryCallbacks,
EntitySourceDefinitions  $entitySourceDefinitions,
EntitySource  $localEntitySource,
InterwikiLookup  $interwikiLookup = null 
)
Parameters
string[]$entityContentModelsEntity type ID to content model ID mapping.
callable[]$entityHandlerFactoryCallbacksEntity type ID to callback mapping for creating ContentHandler objects.
EntitySourceDefinitions$entitySourceDefinitions
EntitySource$localEntitySource
InterwikiLookup | null$interwikiLookup

Member Function Documentation

◆ entityNotFromLocalEntitySource()

Wikibase\Repo\Content\EntityContentFactory::entityNotFromLocalEntitySource ( EntityId  $id)
private

◆ getContentHandlerForType()

Wikibase\Repo\Content\EntityContentFactory::getContentHandlerForType ( string  $entityType)

Returns the EntityHandler for the given entity type.

Parameters
string$entityType
Exceptions
OutOfBoundsExceptionif no content model is defined for the given entity type.
Returns
EntityHandler

◆ getContentModelForType()

Wikibase\Repo\Content\EntityContentFactory::getContentModelForType ( string  $entityType)

Determines what content model is suitable for the given type of entities.

Parameters
string$entityType
Exceptions
OutOfBoundsExceptionif no content model is defined for the given entity type.
Returns
string

◆ getEntityContentModels()

Wikibase\Repo\Content\EntityContentFactory::getEntityContentModels ( )
Returns
string[] A list of content model IDs used to represent Wikibase entities.

◆ getEntityHandlerForContentModel()

Wikibase\Repo\Content\EntityContentFactory::getEntityHandlerForContentModel ( string  $contentModel)

Returns the EntityHandler for the given model id.

Parameters
string$contentModel
Exceptions
OutOfBoundsExceptionif no entity handler is defined for the given content model.
Returns
EntityHandler

◆ getEntityIdForTitle()

Wikibase\Repo\Content\EntityContentFactory::getEntityIdForTitle ( Title  $title)

Returns the ID of the entity associated with the given page title.

Note
There is no guarantee that the EntityId returned by this method refers to an existing entity.
Parameters
Title$title
Returns
EntityId|null

Implements Wikibase\Lib\Store\EntityIdLookup.

◆ getEntityIds()

Wikibase\Repo\Content\EntityContentFactory::getEntityIds ( array  $titles)
See also
EntityIdLookup::getEntityIds
Note
the current implementation skips non-existing entities, but there is no guarantee that this will always be the case.
Parameters
Title[]$titles
Exceptions
StorageException
Returns
EntityId[] Entity IDs, keyed by page IDs.

Implements Wikibase\Lib\Store\EntityIdLookup.

◆ getEntityTypes()

Wikibase\Repo\Content\EntityContentFactory::getEntityTypes ( )
Returns
string[] A list of entity type IDs used for Wikibase entities.

◆ getNamespaceForType()

Wikibase\Repo\Content\EntityContentFactory::getNamespaceForType ( string  $entityType)

Determines what namespace is suitable for the given type of entities.

Parameters
string$entityType
Exceptions
OutOfBoundsExceptionif no content model is defined for the given entity type.
Returns
int

◆ getSlotRoleForType()

Wikibase\Repo\Content\EntityContentFactory::getSlotRoleForType ( string  $entityType)

Determines which slot is used to store a given type of entities.

Parameters
string$entityType
Exceptions
OutOfBoundsExceptionif no content model is defined for the given entity type.
Returns
string the role name of the slot

◆ getTitleForFederatedId()

Wikibase\Repo\Content\EntityContentFactory::getTitleForFederatedId ( EntityId  $id)
private

If the EntityId is federated, return a Title for it.

Otherwise return null

Parameters
EntityId$id
Returns
null|Title

◆ getTitleForId()

Wikibase\Repo\Content\EntityContentFactory::getTitleForId ( EntityId  $id)

Returns the Title object for the item with provided id.

Parameters
EntityId$id
Exceptions
MWException
OutOfBoundsException
InvalidArgumentException
Returns
Title|null

Implements Wikibase\Lib\Store\EntityTitleLookup.

◆ getTitlesForIds()

Wikibase\Repo\Content\EntityContentFactory::getTitlesForIds ( array  $ids)

Returns Title objects for the entities with provided ids.

Parameters
EntityId[]$ids
Exceptions
MWException
OutOfBoundsException
InvalidArgumentException
Returns
(Title|null)[]

Implements Wikibase\Lib\Store\EntityTitleLookup.

◆ isEntityContentModel()

Wikibase\Repo\Content\EntityContentFactory::isEntityContentModel ( string  $contentModel)

Determines whether the given content model is designated to hold some kind of Wikibase entity.

Parameters
string$contentModel
Returns
bool If the given content model ID is a known entity content model.

◆ newFromEntity()

Wikibase\Repo\Content\EntityContentFactory::newFromEntity ( EntityDocument  $entity)

Constructs a new EntityContent from an Entity.

See also
EntityHandler::makeEntityContent
Parameters
EntityDocument$entity
Returns
EntityContent

◆ newFromRedirect()

Wikibase\Repo\Content\EntityContentFactory::newFromRedirect ( EntityRedirect  $redirect)

Constructs a new EntityContent from an EntityRedirect, or null if the respective kind of entity does not support redirects.

See also
EntityHandler::makeEntityRedirectContent
Parameters
EntityRedirect$redirect
Returns
EntityContent|null

Member Data Documentation

◆ $entityContentModels

Wikibase\Repo\Content\EntityContentFactory::$entityContentModels
private

◆ $entityHandlerFactoryCallbacks

Wikibase\Repo\Content\EntityContentFactory::$entityHandlerFactoryCallbacks
private

◆ $entityHandlers

Wikibase\Repo\Content\EntityContentFactory::$entityHandlers = []
private

◆ $entitySourceDefinitions

Wikibase\Repo\Content\EntityContentFactory::$entitySourceDefinitions
private

◆ $interwikiLookup

Wikibase\Repo\Content\EntityContentFactory::$interwikiLookup
private

◆ $localEntitySource

Wikibase\Repo\Content\EntityContentFactory::$localEntitySource
private

◆ $titleForIdCache

Wikibase\Repo\Content\EntityContentFactory::$titleForIdCache
private

The documentation for this class was generated from the following file: