Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\LabelDescriptionDuplicateDetector Class Reference

Detector of label/description uniqueness constraint violations. More...

Public Member Functions

 __construct (LabelConflictFinder $conflictFinder)
 
 detectLabelConflicts ( $entityType, array $labels, array $aliases=null, EntityId $ignoreEntityId=null)
 Detects conflicting labels and aliases.
 
 detectLabelDescriptionConflicts ( $entityType, array $labels, array $descriptions, EntityId $ignoreEntityId=null)
 Detects conflicting combinations of labels and descriptions.
 

Private Member Functions

 termsToErrors ( $message, $errorCode, array $terms)
 
 filterSelfConflicts (array $terms, EntityId $entityId)
 

Private Attributes

 $conflictFinder
 

Detailed Description

Detector of label/description uniqueness constraint violations.

Builds on top of LabelConflictFinder adding handling of self-conflicts and localization.

See also
LabelConflictFinder
Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\LabelDescriptionDuplicateDetector::__construct ( LabelConflictFinder  $conflictFinder)

Member Function Documentation

◆ detectLabelConflicts()

Wikibase\Repo\LabelDescriptionDuplicateDetector::detectLabelConflicts (   $entityType,
array  $labels,
array  $aliases = null,
EntityId  $ignoreEntityId = null 
)

Detects conflicting labels and aliases.

A conflict arises when another entity has the same label or alias for a given language as is present in $label or $aliases. If $aliases is null, only conflicts between labels are considered. If $aliases is not null (but possibly empty), conflicts are also detected between labels and aliases, in any combination.

Parameters
string$entityTypeThe type of entity to search for conflicts.
string[]$labelsAn associative array of labels, with language codes as the keys.
array[] | null$aliasesAliases to be considered to be conflicting with labels. Ignored if descriptions are given.
EntityId | null$ignoreEntityIdConflicts with this entity will be considered self-conflicts and ignored.
Exceptions
InvalidArgumentException
Returns
Result

◆ detectLabelDescriptionConflicts()

Wikibase\Repo\LabelDescriptionDuplicateDetector::detectLabelDescriptionConflicts (   $entityType,
array  $labels,
array  $descriptions,
EntityId  $ignoreEntityId = null 
)

Detects conflicting combinations of labels and descriptions.

A conflict arises when an entity (other than the one given by $ignoreEntityId, if any) has the same combination of label and non-empty description for a given language as is present tin the $label and $description parameters.

Parameters
string$entityTypeThe type of entity to search for conflicts.
string[]$labelsAn associative array of labels, with language codes as the keys.
string[]$descriptionsAn associative array of descriptions, with language codes as the keys.
EntityId | null$ignoreEntityIdConflicts with this entity will be considered self-conflicts and ignored.
Exceptions
InvalidArgumentException
Returns
Result

◆ filterSelfConflicts()

Wikibase\Repo\LabelDescriptionDuplicateDetector::filterSelfConflicts ( array  $terms,
EntityId  $entityId 
)
private
Parameters
TermIndexEntry[]$terms
EntityId$entityId
Returns
TermIndexEntry[]

◆ termsToErrors()

Wikibase\Repo\LabelDescriptionDuplicateDetector::termsToErrors (   $message,
  $errorCode,
array  $terms 
)
private
Parameters
string$messagePlain text message (English)
string$errorCodeError code (for later localization)
TermIndexEntry[]$termsThe conflicting terms.
Returns
UniquenessViolation[]

Member Data Documentation

◆ $conflictFinder

Wikibase\Repo\LabelDescriptionDuplicateDetector::$conflictFinder
private

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