Wikibase
MediaWiki Wikibase extension
|
Transforms usage aspect based on a filter of aspects relevant in some context. More...
Public Member Functions | |
setRelevantAspects (EntityId $entityId, array $aspects) | |
getRelevantAspects (EntityId $entityId) | |
getFilteredUsages (EntityId $entityId, array $aspects) | |
Gets EntityUsage objects for each aspect in $aspects that is relevant according to getRelevantAspects( $entityId ). | |
transformPageEntityUsages (PageEntityUsages $pageEntityUsages) | |
Transforms the entity usages from $pageEntityUsages according to the relevant aspects defined by calling setRelevantAspects(). | |
Private Member Functions | |
buildEntityUsages (EntityId $entityId, array $aspects) | |
getFilteredAspects (array $aspectKeys, array $relevant) | |
Filter $aspects based on the aspects provided by $relevant, according to the rules defined for combining aspects (see class level documentation). | |
includeGeneralUsages (array $relevantKeys, array $aspectKeys, array &$aspects) | |
Makes general (modifier less) usages trigger the associated relevant specialized aspects. | |
Private Attributes | |
$relevantAspectsPerEntity | |
Transforms usage aspect based on a filter of aspects relevant in some context.
Relevant aspects for each entity are collected using the setRelevantAspects() method.
Example: If a page uses the "label" (L) and "title" (T) aspects of item Q1, a UsageAspectTransformer that was set up to consider the label aspect of Q1 to be relevant will transform the usage Q1::L + Q1::T to the "relevant" usage Q1::L.
Example: The "all" (X) aspect is treated specially: If a page uses the X aspect, a UsageAspectTransformer that was constructed to consider e.g. the label and title aspects of Q1 to be relevant will transform the usage Q1::X to the "relevant" usage Q1::L + Q1::T. Conversely, if a page uses the "sitelink" (S) aspect, a UsageAspectTransformer that was constructed to consider all (X) usages relevant will keep the usage Q1::S usage as "relevant".
|
private |
EntityId | $entityId | |
string[] | $aspects | (may have modifiers applied) |
|
private |
Filter $aspects based on the aspects provided by $relevant, according to the rules defined for combining aspects (see class level documentation).
string[] | $aspectKeys | Array of aspect keys, with modifiers applied. |
string[] | $relevant | Array of aspect keys, with modifiers applied. |
Wikibase\Client\Usage\UsageAspectTransformer::getFilteredUsages | ( | EntityId | $entityId, |
array | $aspects ) |
Gets EntityUsage objects for each aspect in $aspects that is relevant according to getRelevantAspects( $entityId ).
Example: If was called with setRelevantAspects( $q3, [ 'T', 'L.de', 'L.en' ] ), getFilteredUsages( $q3, [ 'S', 'L' ] ) will return EntityUsage( $q3, 'L.de', 'L.en' ), while getFilteredUsages( $q3, [ 'X' ] ) will return EntityUsage( $q3, 'T' ) and EntityUsage( $q3, 'L' ).
EntityId | $entityId | |
string[] | $aspects |
Wikibase\Client\Usage\UsageAspectTransformer::getRelevantAspects | ( | EntityId | $entityId | ) |
EntityId | $entityId |
|
private |
Makes general (modifier less) usages trigger the associated relevant specialized aspects.
For example matches 'L' in $aspectKeys to 'L.xx' in $relevantKeys.
string[] | $relevantKeys | Array of potentially relevant aspect keys, with modifiers applied. |
string[] | $aspectKeys | Array of actually used aspects keys, with modifiers applied. |
array | &$aspects | Associative array of aspect keys (with modifiers) as keys, the values being meaningless (a.k.a. HashSet). |
Wikibase\Client\Usage\UsageAspectTransformer::setRelevantAspects | ( | EntityId | $entityId, |
array | $aspects ) |
EntityId | $entityId | |
string[] | $aspects |
Wikibase\Client\Usage\UsageAspectTransformer::transformPageEntityUsages | ( | PageEntityUsages | $pageEntityUsages | ) |
Transforms the entity usages from $pageEntityUsages according to the relevant aspects defined by calling setRelevantAspects().
A new PageEntityUsages containing the filtered usage list is returned.
PageEntityUsages | $pageEntityUsages |
|
private |