Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Client\Usage\EntityUsage Class Reference

Value object representing the usage of an entity. More...

Public Member Functions

 __construct (EntityId $entityId, $aspect, $modifier=null)
 
 getAspect ()
 
 getModifier ()
 
 getAspectKey ()
 Returns the aspect with the modifier applied.
 
 getEntityId ()
 
 getIdentityString ()
 
 __toString ()
 
 asArray ()
 

Static Public Member Functions

static stripModifier ( $aspectKey)
 
static splitAspectKey ( $aspectKey)
 Splits the given aspect key into aspect and modifier (if any).
 
static makeAspectKey ( $aspect, $modifier=null)
 Composes an aspect key from aspect and modifier (if any).
 

Public Attributes

const SITELINK_USAGE = 'S'
 Usage flag indicating that the entity's sitelinks were used as links.
 
const LABEL_USAGE = 'L'
 Usage flag indicating that one of the entity's labels were used.
 
const DESCRIPTION_USAGE = 'D'
 Usage flag indicating that one of the entity's descriptions were used.
 
const TITLE_USAGE = 'T'
 Usage flag indicating that the entity's local page name was used.
 
const STATEMENT_USAGE = 'C'
 Usage flag indicating that certain statements (identified by their property id) from the entity were used.
 
const ALL_USAGE = 'X'
 Usage flag indicating that any and all aspects of the entity were (or may have been) used.
 
const OTHER_USAGE = 'O'
 Usage flag indicating that some aspect of the entity was changed which is not covered by any other usage flag (except "all").
 

Private Attributes

 $entityId
 
 $aspect
 
 $modifier
 
 $identity
 

Static Private Attributes

static $aspects
 

Detailed Description

Value object representing the usage of an entity.

This includes information about how the entity is used, but not where.

See also
docs/usagetracking.wiki
Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\Usage\EntityUsage::__construct ( EntityId  $entityId,
  $aspect,
  $modifier = null 
)
Parameters
EntityId$entityId
string$aspectuse the EntityUsage::XXX_USAGE constants
string | null$modifierfor further qualifying the usage aspect (e.g. a language code may be used along with the LABEL_USAGE aspect.
Exceptions
InvalidArgumentException

Member Function Documentation

◆ __toString()

Wikibase\Client\Usage\EntityUsage::__toString ( )
Returns
string

◆ asArray()

Wikibase\Client\Usage\EntityUsage::asArray ( )
Returns
array ( 'entityId' => string $entityId, 'aspect' => string $aspect, 'modifier' => string|null $modifier ) -return array{entityId:string,aspect:string,modifier:?string}

◆ getAspect()

Wikibase\Client\Usage\EntityUsage::getAspect ( )
Returns
string

◆ getAspectKey()

Wikibase\Client\Usage\EntityUsage::getAspectKey ( )

Returns the aspect with the modifier applied.

See also
makeAspectKey
Returns
string

◆ getEntityId()

Wikibase\Client\Usage\EntityUsage::getEntityId ( )
Returns
EntityId

◆ getIdentityString()

Wikibase\Client\Usage\EntityUsage::getIdentityString ( )
Returns
string

◆ getModifier()

Wikibase\Client\Usage\EntityUsage::getModifier ( )
Returns
null|string

◆ makeAspectKey()

static Wikibase\Client\Usage\EntityUsage::makeAspectKey (   $aspect,
  $modifier = null 
)
static

Composes an aspect key from aspect and modifier (if any).

This is the inverse of splitAspectKey().

Parameters
string$aspect
string | null$modifier
Returns
string "$aspect.$modifier"

◆ splitAspectKey()

static Wikibase\Client\Usage\EntityUsage::splitAspectKey (   $aspectKey)
static

Splits the given aspect key into aspect and modifier (if any).

This is the inverse of makeAspectKey().

Parameters
string$aspectKey
Returns
string[] list( $aspect, $modifier )

◆ stripModifier()

static Wikibase\Client\Usage\EntityUsage::stripModifier (   $aspectKey)
static
Parameters
string$aspectKey
Returns
string One of the EntityUsage::..._USAGE constants with the modifier split off.

Member Data Documentation

◆ $aspect

Wikibase\Client\Usage\EntityUsage::$aspect
private

◆ $aspects

Wikibase\Client\Usage\EntityUsage::$aspects
staticprivate
Initial value:
= [
self::SITELINK_USAGE => null,
self::LABEL_USAGE => null,
self::DESCRIPTION_USAGE => null,
self::TITLE_USAGE => null,
self::STATEMENT_USAGE => null,
self::OTHER_USAGE => null,
self::ALL_USAGE => null,
]

◆ $entityId

Wikibase\Client\Usage\EntityUsage::$entityId
private

◆ $identity

Wikibase\Client\Usage\EntityUsage::$identity
private

◆ $modifier

Wikibase\Client\Usage\EntityUsage::$modifier
private

◆ ALL_USAGE

const Wikibase\Client\Usage\EntityUsage::ALL_USAGE = 'X'

Usage flag indicating that any and all aspects of the entity were (or may have been) used.

◆ DESCRIPTION_USAGE

const Wikibase\Client\Usage\EntityUsage::DESCRIPTION_USAGE = 'D'

Usage flag indicating that one of the entity's descriptions were used.

This would be the case when showing the descriptions of a referenced entity. Note that descriptions usage is typically tracked with a modifier specifying the language code.

◆ LABEL_USAGE

const Wikibase\Client\Usage\EntityUsage::LABEL_USAGE = 'L'

Usage flag indicating that one of the entity's labels were used.

This would be the case when showing the label of a referenced entity. Note that label usage is typically tracked with a modifier specifying the label's language code.

◆ OTHER_USAGE

const Wikibase\Client\Usage\EntityUsage::OTHER_USAGE = 'O'

Usage flag indicating that some aspect of the entity was changed which is not covered by any other usage flag (except "all").

That is, the specific usage flags together with the "other" flag are equivalent to the "all" flag ( S + T + L + O = X or rather O = X - S - T - L ).

This currently covers alias usage and entity existence checks.

◆ SITELINK_USAGE

const Wikibase\Client\Usage\EntityUsage::SITELINK_USAGE = 'S'

Usage flag indicating that the entity's sitelinks were used as links.

This would be the case when generating language links or sister links from an entity's sitelinks, for display in the sidebar.

Note
: This does NOT cover sitelinks used in wikitext (e.g. via Lua). Use OTHER_USAGE for that.

◆ STATEMENT_USAGE

const Wikibase\Client\Usage\EntityUsage::STATEMENT_USAGE = 'C'

Usage flag indicating that certain statements (identified by their property id) from the entity were used.

This currently implies that we also have an OTHER_USAGE or an ALL_USAGE for the same entity (STATEMENT_USAGE is never used alone).

◆ TITLE_USAGE

const Wikibase\Client\Usage\EntityUsage::TITLE_USAGE = 'T'

Usage flag indicating that the entity's local page name was used.

This would be the case when linking a referenced entity to the corresponding local wiki page.


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