/** * @param Property $property * * @return array[] */ private function toDiffArray(Property $property) { $array = array(); $array['aliases'] = $property->getFingerprint()->getAliasGroups()->toTextArray(); $array['label'] = $property->getFingerprint()->getLabels()->toTextArray(); $array['description'] = $property->getFingerprint()->getDescriptions()->toTextArray(); return $array; }
private function addTermsToSerialization(Property $property, array &$serialization) { $fingerprint = $property->getFingerprint(); $serialization['labels'] = $this->termListSerializer->serialize($fingerprint->getLabels()); $serialization['descriptions'] = $this->termListSerializer->serialize($fingerprint->getDescriptions()); $serialization['aliases'] = $this->aliasGroupListSerializer->serialize($fingerprint->getAliasGroups()); }
public function testGivenKnownPropertyId_propertyLabelIsReturned() { $property = new Property(new PropertyId('P1337'), null, 'string'); $property->getFingerprint()->setLabel('en', 'postal code'); $this->testEnvironment->insertProperty($property); $client = $this->createClient(); $client->request('GET', '/properties/P1337/label'); $this->assertSuccessResponse('postal code', $client->getResponse()); }
public function testGivenKnownPropertyId_propertyLabelIsReturned() { $property = new Property(new PropertyId('P1337'), null, 'string'); $property->getFingerprint()->setAliasGroup('en', ['foo', 'bar', 'baz']); $this->testEnvironment->insertProperty($property); $client = $this->createClient(); $client->request('GET', '/properties/P1337/aliases'); $this->assertSuccessResponse(['foo', 'bar', 'baz'], $client->getResponse()); }
public function testGivenKnownPropertyId_propertyDescriptionIsReturned() { $property = new Property(new PropertyId('P1337'), null, 'string'); $property->getFingerprint()->setDescription('en', 'foo bar baz'); $this->testEnvironment->insertProperty($property); $client = $this->createClient(); $client->request('GET', '/properties/P1337/description'); $this->assertSuccessResponse('foo bar baz', $client->getResponse()); }
/** * Returns a MockRepository. The following entities are defined: * * - Items Q23 * - Item Q42 * - Redirect Q2233 -> Q23 * - Redirect Q222333 -> Q23 * - Property P5 (item reference) * * @return MockRepository */ private function getMockRepository() { $mockRepo = new MockRepository(); $p5 = new Property(new PropertyId('P5'), null, 'wikibase-item'); $p5->getFingerprint()->setLabel('en', 'Label5'); $mockRepo->putEntity($p5); $q23 = new Item(new ItemId('Q23')); $q23->getFingerprint()->setLabel('en', 'Label23'); $mockRepo->putEntity($q23); $q2233 = new EntityRedirect(new ItemId('Q2233'), new ItemId('Q23')); $mockRepo->putRedirect($q2233); $q222333 = new EntityRedirect(new ItemId('Q222333'), new ItemId('Q23')); $mockRepo->putRedirect($q222333); $q42 = new Item(new ItemId('Q42')); $q42->getFingerprint()->setLabel('en', 'Label42'); $snak = new PropertyValueSnak($p5->getId(), new EntityIdValue($q2233->getEntityId())); $q42->getStatements()->addNewStatement($snak, null, null, 'Q42$DEADBEEF'); $mockRepo->putEntity($q42); return $mockRepo; }
private function setTermsFromSerialization(array $serialization, Property $property) { if (array_key_exists('labels', $serialization)) { $this->assertAttributeIsArray($serialization, 'labels'); $property->getFingerprint()->setLabels($this->termListDeserializer->deserialize($serialization['labels'])); } if (array_key_exists('descriptions', $serialization)) { $this->assertAttributeIsArray($serialization, 'descriptions'); $property->getFingerprint()->setDescriptions($this->termListDeserializer->deserialize($serialization['descriptions'])); } if (array_key_exists('aliases', $serialization)) { $this->assertAttributeIsArray($serialization, 'aliases'); $property->getFingerprint()->setAliasGroups($this->aliasGroupListDeserializer->deserialize($serialization['aliases'])); } }
private function addAliases() { if ($this->property->getFingerprint()->hasAliasGroup($this->languageCode)) { $this->simpleProperty->aliases = $this->property->getFingerprint()->getAliasGroup($this->languageCode)->getAliases(); } }
private function patchProperty(Property $property, EntityDiff $patch) { $this->fingerprintPatcher->patchFingerprint($property->getFingerprint(), $patch); $property->setStatements($this->statementListPatcher->getPatchedStatementList($property->getStatements(), $patch->getClaimsDiff())); }