本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::setStatements方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::setStatements方法的具体用法?PHP Item::setStatements怎么用?PHP Item::setStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikibase\DataModel\Entity\Item
的用法示例。
在下文中一共展示了Item::setStatements方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeEntity
protected function makeEntity(EntityId $id, array $statements = array())
{
$item = new Item($id);
$item->setLabel('en', "label:{$id}");
$item->setDescription('en', "description:{$id}");
$item->setStatements(new StatementList($statements));
return $item;
}
示例2: patchItem
private function patchItem(Item $item, EntityDiff $patch)
{
$this->fingerprintPatcher->patchFingerprint($item->getFingerprint(), $patch);
if ($patch instanceof ItemDiff) {
$item->setSiteLinkList($this->siteLinkListPatcher->getPatchedSiteLinkList($item->getSiteLinkList(), $patch->getSiteLinkDiff()));
}
$item->setStatements($this->statementListPatcher->getPatchedStatementList($item->getStatements(), $patch->getClaimsDiff()));
}
示例3: setStatementListFromSerialization
private function setStatementListFromSerialization(array $serialization, Item $item)
{
if (!array_key_exists('claims', $serialization)) {
return;
}
$statements = $this->statementListDeserializer->deserialize($serialization['claims']);
$item->setStatements($statements);
}
示例4: provideData
/**
* @return array 1=>from 2=>to 3=>expectedFrom 4=>expectedTo
*/
public function provideData()
{
$testCases = array();
$itemWithEnLabel = new Item();
$itemWithEnLabel->getFingerprint()->setLabel('en', 'foo');
$testCases['labelMerge'] = array($itemWithEnLabel->copy(), new Item(), new Item(), $itemWithEnLabel->copy());
$testCases['identicalLabelMerge'] = array($itemWithEnLabel->copy(), $itemWithEnLabel->copy(), new Item(), $itemWithEnLabel->copy());
$itemWithEnBarLabel = new Item();
$itemWithEnBarLabel->getFingerprint()->setLabel('en', 'bar');
$itemWithLabelAndAlias = new Item();
$itemWithLabelAndAlias->getFingerprint()->setLabel('en', 'bar');
$itemWithLabelAndAlias->getFingerprint()->setAliasGroup('en', array('foo'));
$testCases['labelAsAliasMerge'] = array($itemWithEnLabel->copy(), $itemWithEnBarLabel->copy(), new Item(), $itemWithLabelAndAlias->copy());
$itemWithDescription = new Item();
$itemWithDescription->getFingerprint()->setDescription('en', 'foo');
$testCases['descriptionMerge'] = array($itemWithDescription->copy(), new Item(), new Item(), $itemWithDescription->copy());
$testCases['identicalDescriptionMerge'] = array($itemWithDescription->copy(), $itemWithDescription->copy(), new Item(), $itemWithDescription->copy());
$itemWithBarDescription = new Item();
$itemWithBarDescription->getFingerprint()->setDescription('en', 'bar');
$testCases['ignoreConflictDescriptionMerge'] = array($itemWithDescription->copy(), $itemWithBarDescription->copy(), $itemWithDescription->copy(), $itemWithBarDescription->copy(), array('description'));
$itemWithFooBarAliases = new Item();
$itemWithFooBarAliases->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
$testCases['aliasMerge'] = array($itemWithFooBarAliases->copy(), new Item(), new Item(), $itemWithFooBarAliases->copy());
$itemWithFooBarBazAliases = new Item();
$itemWithFooBarBazAliases->getFingerprint()->setAliasGroup('en', array('foo', 'bar', 'baz'));
$testCases['duplicateAliasMerge'] = array($itemWithFooBarAliases->copy(), $itemWithFooBarBazAliases->copy(), new Item(), $itemWithFooBarBazAliases->copy());
$itemWithLink = new Item();
$itemWithLink->getSiteLinkList()->addNewSiteLink('enwiki', 'foo');
$testCases['linkMerge'] = array($itemWithLink->copy(), new Item(), new Item(), $itemWithLink->copy());
$testCases['sameLinkLinkMerge'] = array($itemWithLink->copy(), $itemWithLink->copy(), new Item(), $itemWithLink->copy());
$itemWithBarLink = new Item();
$itemWithBarLink->getSiteLinkList()->addNewSiteLink('enwiki', 'bar');
$testCases['ignoreConflictLinkMerge'] = array($itemWithLink->copy(), $itemWithBarLink->copy(), $itemWithLink->copy(), $itemWithBarLink->copy(), array('sitelink'));
$statement = new Statement(new PropertyNoValueSnak(new PropertyId('P56')));
$statement->setGuid('Q111$D8404CDA-25E4-4334-AF13-A390BCD9C556');
$itemWithStatement = new Item();
$itemWithStatement->getStatements()->addStatement($statement);
$testCases['statementMerge'] = array($itemWithStatement->copy(), new Item(), new Item(), $itemWithStatement->copy());
$qualifiedStatement = new Statement(new PropertyNoValueSnak(new PropertyId('P56')), new SnakList(array(new PropertyNoValueSnak(new PropertyId('P56')))));
$qualifiedStatement->setGuid('Q111$D8404CDA-25E4-4334-AF13-A390BCD9C556');
$itemWithQualifiedStatement = new Item();
$itemWithQualifiedStatement->getStatements()->addStatement($qualifiedStatement);
$testCases['statementWithQualifierMerge'] = array($itemWithQualifiedStatement->copy(), new Item(), new Item(), $itemWithQualifiedStatement->copy());
$anotherQualifiedStatement = new Statement(new PropertyNoValueSnak(new PropertyId('P88')), new SnakList(array(new PropertyNoValueSnak(new PropertyId('P88')))));
$anotherQualifiedStatement->setGuid('Q111$D8404CDA-25E4-4334-AF88-A3290BCD9C0F');
$selfReferencingStatement = new Statement(new PropertyValueSnak(new PropertyId('P42'), new EntityIdValue(new ItemId('Q111'))));
$selfReferencingStatement->setGuid('Q111$D74D43D7-BD8F-4240-A058-24C5171ABBFA');
$bigItem = new Item();
$bigItem->setId(111);
$bigItem->getFingerprint()->setLabel('en', 'foo');
$bigItem->getFingerprint()->setLabel('pt', 'ptfoo');
$bigItem->getFingerprint()->setDescription('en', 'foo');
$bigItem->getFingerprint()->setDescription('pl', 'pldesc');
$bigItem->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
$bigItem->getFingerprint()->setAliasGroup('de', array('defoo', 'debar'));
$bigItem->getSiteLinkList()->addNewSiteLink('dewiki', 'foo');
$bigItem->getStatements()->addStatement($anotherQualifiedStatement);
$bigItem->getStatements()->addStatement($selfReferencingStatement);
$testCases['itemMerge'] = array($bigItem->copy(), new Item(), new Item(), $bigItem->copy());
$referencingStatement = new Statement(new PropertyValueSnak(new PropertyId('P42'), new EntityIdValue(new ItemId('Q222'))));
$referencingStatement->setGuid('Q111$949A4D27-0EBC-46A7-BF5F-AA2DD33C0443');
$bigItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'bar');
$bigItem->getStatements()->addStatement($referencingStatement);
$smallerItem = new Item();
$smallerItem->setId(222);
$smallerItem->getFingerprint()->setLabel('en', 'toLabel');
$smallerItem->getFingerprint()->setDescription('pl', 'toDescription');
$smallerItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'toLink');
$smallerMergedItem = new Item();
$smallerMergedItem->setId(222);
$smallerMergedItem->getFingerprint()->setDescription('pl', 'pldesc');
$smallerMergedItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'bar');
$bigMergedItem = new Item();
$bigMergedItem->setId(111);
$bigMergedItem->getFingerprint()->setLabel('en', 'toLabel');
$bigMergedItem->getFingerprint()->setLabel('pt', 'ptfoo');
$bigMergedItem->getFingerprint()->setDescription('en', 'foo');
$bigMergedItem->getFingerprint()->setDescription('pl', 'toDescription');
$bigMergedItem->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
$bigMergedItem->getFingerprint()->setAliasGroup('de', array('defoo', 'debar'));
$bigMergedItem->getSiteLinkList()->addNewSiteLink('dewiki', 'foo');
$bigMergedItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'toLink');
$bigMergedItem->setStatements(new StatementList($anotherQualifiedStatement, $selfReferencingStatement, $referencingStatement));
$testCases['ignoreConflictItemMerge'] = array($bigItem->copy(), $smallerItem->copy(), $smallerMergedItem->copy(), $bigMergedItem->copy(), array('description', 'sitelink', 'statement'));
return $testCases;
}
示例5: createTestItem
/**
* @param ItemId $id
* @param string[] $labels
* @param Statement[]|null $statements
* @param SiteLink[]|null $siteLinks
*
* @return Item
*/
private function createTestItem(ItemId $id, array $labels, array $statements = null, array $siteLinks = null)
{
$item = new Item($id);
$item->getFingerprint()->setDescription('de', 'Description of ' . $id->getSerialization());
foreach ($labels as $lang => $label) {
$item->setLabel($lang, $label);
}
if ($statements !== null) {
$item->setStatements(new StatementList($statements));
}
if ($siteLinks !== null) {
$item->setSiteLinkList(new SiteLinkList($siteLinks));
}
$this->siteLinkLookup->putEntity($item);
return $item;
}
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:24,代码来源:WikibaseDataAccessTestItemSetUpHelper.php
示例6: testSetStatements
public function testSetStatements()
{
$item = new Item();
$item->getStatements()->addNewStatement(new PropertyNoValueSnak(42));
$item->setStatements(new StatementList());
$this->assertTrue($item->getStatements()->isEmpty());
}
示例7: testNewFromUpdate_excludeStatementsInDiffs
public function testNewFromUpdate_excludeStatementsInDiffs()
{
$factory = $this->getEntityChangeFactory();
$item = new Item(new ItemId('Q3'));
$statementList = new StatementList(array(new Statement(new PropertyNoValueSnak(9000))));
$item->setStatements($statementList);
$updatedItem = new Item(new ItemId('Q3'));
$statementList = new StatementList(array(new Statement(new PropertyNoValueSnak(10))));
$updatedItem->setStatements($statementList);
$change = $factory->newFromUpdate(EntityChange::UPDATE, $item, $updatedItem);
$this->assertTrue($change->getDiff()->isEmpty(), 'Diff excludes statement changes and is empty');
}