77use Wikibase \DataModel \Term \AliasGroupList ;
88use Wikibase \DataModel \Term \Fingerprint ;
99use Wikibase \DataModel \Term \FingerprintProvider ;
10- use Wikibase \DataModel \Term \Term ;
1110use Wikibase \DataModel \Term \TermList ;
1211
1312/**
2221 */
2322abstract class Entity implements \Comparable, FingerprintProvider, EntityDocument {
2423
25- /**
26- * @var EntityId|null
27- */
28- protected $ id ;
29-
30- /**
31- * @var Fingerprint
32- */
33- protected $ fingerprint ;
34-
35- /**
36- * Returns the id of the entity or null if it does not have one.
37- *
38- * @since 0.1 return type changed in 0.3
39- *
40- * @return EntityId|null
41- */
42- public function getId () {
43- return $ this ->id ;
44- }
45-
4624 /**
4725 * Sets the value for the label in a certain value.
4826 *
@@ -52,7 +30,7 @@ public function getId() {
5230 * @param string $value
5331 */
5432 public function setLabel ( $ languageCode , $ value ) {
55- $ this ->fingerprint ->setLabel ( $ languageCode , $ value );
33+ $ this ->getFingerprint () ->setLabel ( $ languageCode , $ value );
5634 }
5735
5836 /**
@@ -64,7 +42,7 @@ public function setLabel( $languageCode, $value ) {
6442 * @param string $value
6543 */
6644 public function setDescription ( $ languageCode , $ value ) {
67- $ this ->fingerprint ->setDescription ( $ languageCode , $ value );
45+ $ this ->getFingerprint () ->setDescription ( $ languageCode , $ value );
6846 }
6947
7048 /**
@@ -75,7 +53,7 @@ public function setDescription( $languageCode, $value ) {
7553 * @param string $languageCode
7654 */
7755 public function removeLabel ( $ languageCode ) {
78- $ this ->fingerprint ->removeLabel ( $ languageCode );
56+ $ this ->getFingerprint () ->removeLabel ( $ languageCode );
7957 }
8058
8159 /**
@@ -86,7 +64,7 @@ public function removeLabel( $languageCode ) {
8664 * @param string $languageCode
8765 */
8866 public function removeDescription ( $ languageCode ) {
89- $ this ->fingerprint ->removeDescription ( $ languageCode );
67+ $ this ->getFingerprint () ->removeDescription ( $ languageCode );
9068 }
9169
9270 /**
@@ -99,7 +77,7 @@ public function removeDescription( $languageCode ) {
9977 * @return string[]
10078 */
10179 public function getAliases ( $ languageCode ) {
102- $ aliases = $ this ->fingerprint ->getAliasGroups ();
80+ $ aliases = $ this ->getFingerprint () ->getAliasGroups ();
10381
10482 if ( $ aliases ->hasGroupForLanguage ( $ languageCode ) ) {
10583 return $ aliases ->getByLanguage ( $ languageCode )->getAliases ();
@@ -119,7 +97,7 @@ public function getAliases( $languageCode ) {
11997 * @return array[]
12098 */
12199 public function getAllAliases ( array $ languageCodes = null ) {
122- $ aliases = $ this ->fingerprint ->getAliasGroups ();
100+ $ aliases = $ this ->getFingerprint () ->getAliasGroups ();
123101
124102 $ textLists = array ();
125103
@@ -144,7 +122,7 @@ public function getAllAliases( array $languageCodes = null ) {
144122 * @param string[] $aliases
145123 */
146124 public function setAliases ( $ languageCode , array $ aliases ) {
147- $ this ->fingerprint ->setAliasGroup ( $ languageCode , $ aliases );
125+ $ this ->getFingerprint () ->setAliasGroup ( $ languageCode , $ aliases );
148126 }
149127
150128 /**
@@ -222,11 +200,11 @@ public function getLabels( array $languageCodes = null ) {
222200 * @return string|bool
223201 */
224202 public function getDescription ( $ languageCode ) {
225- if ( !$ this ->fingerprint ->hasDescription ( $ languageCode ) ) {
203+ if ( !$ this ->getFingerprint () ->hasDescription ( $ languageCode ) ) {
226204 return false ;
227205 }
228206
229- return $ this ->fingerprint ->getDescription ( $ languageCode )->getText ();
207+ return $ this ->getFingerprint () ->getDescription ( $ languageCode )->getText ();
230208 }
231209
232210 /**
@@ -240,11 +218,11 @@ public function getDescription( $languageCode ) {
240218 * @return string|bool
241219 */
242220 public function getLabel ( $ languageCode ) {
243- if ( !$ this ->fingerprint ->hasLabel ( $ languageCode ) ) {
221+ if ( !$ this ->getFingerprint () ->hasLabel ( $ languageCode ) ) {
244222 return false ;
245223 }
246224
247- return $ this ->fingerprint ->getLabel ( $ languageCode )->getText ();
225+ return $ this ->getFingerprint () ->getLabel ( $ languageCode )->getText ();
248226 }
249227
250228 /**
@@ -257,9 +235,9 @@ public function getLabel( $languageCode ) {
257235 */
258236 private function getMultilangTexts ( $ fieldKey , array $ languageCodes = null ) {
259237 if ( $ fieldKey === 'label ' ) {
260- $ textList = $ this ->fingerprint ->getLabels ()->toTextArray ();
238+ $ textList = $ this ->getFingerprint () ->getLabels ()->toTextArray ();
261239 } else {
262- $ textList = $ this ->fingerprint ->getDescriptions ()->toTextArray ();
240+ $ textList = $ this ->getFingerprint () ->getDescriptions ()->toTextArray ();
263241 }
264242
265243 if ( $ languageCodes !== null ) {
@@ -280,7 +258,7 @@ private function getMultilangTexts( $fieldKey, array $languageCodes = null ) {
280258 * @param string[] $labels
281259 */
282260 public function setLabels ( array $ labels ) {
283- $ this ->fingerprint ->setLabels ( new TermList () );
261+ $ this ->getFingerprint () ->setLabels ( new TermList () );
284262
285263 foreach ( $ labels as $ languageCode => $ labelText ) {
286264 $ this ->setLabel ( $ languageCode , $ labelText );
@@ -298,7 +276,7 @@ public function setLabels( array $labels ) {
298276 * @param string[] $descriptions
299277 */
300278 public function setDescriptions ( array $ descriptions ) {
301- $ this ->fingerprint ->setDescriptions ( new TermList () );
279+ $ this ->getFingerprint () ->setDescriptions ( new TermList () );
302280
303281 foreach ( $ descriptions as $ languageCode => $ descriptionText ) {
304282 $ this ->setDescription ( $ languageCode , $ descriptionText );
@@ -317,7 +295,7 @@ public function setDescriptions( array $descriptions ) {
317295 * @param array[] $aliasLists
318296 */
319297 public function setAllAliases ( array $ aliasLists ) {
320- $ this ->fingerprint ->setAliasGroups ( new AliasGroupList () );
298+ $ this ->getFingerprint () ->setAliasGroups ( new AliasGroupList () );
321299
322300 foreach ( $ aliasLists as $ languageCode => $ aliasList ) {
323301 $ this ->setAliases ( $ languageCode , $ aliasList );
@@ -346,25 +324,13 @@ public function getClaims() {
346324 return array ();
347325 }
348326
349- /**
350- * @since 0.7.3
351- * @deprecated since 1.0
352- *
353- * @return Fingerprint
354- */
355- public function getFingerprint () {
356- return $ this ->fingerprint ;
357- }
358-
359327 /**
360328 * @since 0.7.3
361329 * @deprecated since 1.0
362330 *
363331 * @param Fingerprint $fingerprint
364332 */
365- public function setFingerprint ( Fingerprint $ fingerprint ) {
366- $ this ->fingerprint = $ fingerprint ;
367- }
333+ public abstract function setFingerprint ( Fingerprint $ fingerprint );
368334
369335 /**
370336 * Returns if the Entity has no content.
0 commit comments