本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::getFingerprint方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getFingerprint方法的具体用法?PHP Item::getFingerprint怎么用?PHP Item::getFingerprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikibase\DataModel\Entity\Item
的用法示例。
在下文中一共展示了Item::getFingerprint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetAliases
/**
* @depends testCreateItem
*/
public function testSetAliases()
{
$factory = $factory = TestEnvironment::newDefault()->getFactory();
$aliasFr = new AliasGroup('fr', array('aa', 'bb'));
$r = $factory->newAliasGroupSetter()->set($aliasFr, self::$itemId);
$this->assertTrue($r);
self::$localItem->getFingerprint()->getAliasGroups()->setGroup($aliasFr);
}
示例2: testPatchesLabels
public function testPatchesLabels()
{
$item = new Item();
$item->getFingerprint()->setLabel('en', 'foo');
$item->getFingerprint()->setLabel('de', 'bar');
$patch = new ItemDiff(array('label' => new Diff(array('en' => new DiffOpChange('foo', 'spam'), 'nl' => new DiffOpAdd('baz')))));
$patchedItem = $this->getPatchedItem($item, $patch);
$this->assertSame(array('en' => 'spam', 'de' => 'bar', 'nl' => 'baz'), $patchedItem->getFingerprint()->getLabels()->toTextArray());
}
示例3: toDiffArray
private function toDiffArray(Item $item)
{
$array = array();
$array['aliases'] = $item->getFingerprint()->getAliasGroups()->toTextArray();
$array['label'] = $item->getFingerprint()->getLabels()->toTextArray();
$array['description'] = $item->getFingerprint()->getDescriptions()->toTextArray();
$array['links'] = $this->getLinksInDiffFormat($item);
return $array;
}
示例4: setUpEntities
private function setUpEntities()
{
global $wgUser;
static $setup = false;
if ($setup) {
return;
}
$setup = true;
$store = WikibaseRepo::getDefaultInstance()->getStore()->getEntityStore();
// remove entities we care about
$idsToDelete = array(new ItemId('Q404'), new ItemId('Q23'), new PropertyId('P404'));
foreach ($idsToDelete as $id) {
try {
$store->deleteEntity($id, 'test', $wgUser);
} catch (StorageException $ex) {
// ignore
}
}
// Set up Q23
$item = new Item(new ItemId('Q23'));
$item->getFingerprint()->setLabel('en', 'George Washington');
// Set up P42
$property = new Property(new PropertyId('P42'), null, 'string');
$store->saveEntity($item, 'testing', $wgUser, EDIT_NEW);
$store->saveEntity($property, 'testing', $wgUser, EDIT_NEW);
}
示例5: generateAliasesChangeOps
private function generateAliasesChangeOps()
{
foreach ($this->fromItem->getFingerprint()->getAliasGroups()->toTextArray() as $langCode => $aliases) {
$this->fromChangeOps->add($this->getFingerprintChangeOpFactory()->newRemoveAliasesOp($langCode, $aliases));
$this->toChangeOps->add($this->getFingerprintChangeOpFactory()->newAddAliasesOp($langCode, $aliases));
}
}
示例6: 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()));
}
示例7: generate
/**
* @param Item $item
*
* @return string
*/
public function generate(Item $item)
{
$fingerprintGenerator = new FingerprintSearchTextGenerator();
$text = $fingerprintGenerator->generate($item->getFingerprint());
foreach ($item->getSiteLinkList()->toArray() as $siteLink) {
$text .= "\n" . $siteLink->getPageName();
}
return trim($text, "\n");
}
示例8: testGivenKnownItemId_itemLabelIsReturned
public function testGivenKnownItemId_itemLabelIsReturned()
{
$item = new Item(new ItemId('Q1337'));
$item->getFingerprint()->setAliasGroup('en', ['foo', 'bar', 'baz']);
$this->testEnvironment->insertItem($item);
$client = $this->createClient();
$client->request('GET', '/items/Q1337/aliases');
$this->assertSuccessResponse(['foo', 'bar', 'baz'], $client->getResponse());
}
示例9: testGivenUntrimmedPageName_generateDoesNotTrim
public function testGivenUntrimmedPageName_generateDoesNotTrim()
{
$item = new Item();
$item->getFingerprint()->setLabel('en', ' untrimmed label ');
$item->getSiteLinkList()->addNewSiteLink('enwiki', ' untrimmed pageName ');
$generator = new ItemSearchTextGenerator();
$text = $generator->generate($item);
$this->assertSame(" untrimmed label \n untrimmed pageName ", $text);
}
示例10: testConstructionDiffContainsAddOperations
public function testConstructionDiffContainsAddOperations()
{
$item = new Item();
$item->getFingerprint()->setLabel('en', 'foo');
$item->getSiteLinkList()->addNewSiteLink('bar', 'baz');
$differ = new ItemDiffer();
$diff = $differ->getConstructionDiff($item);
$this->assertEquals(new Diff(array('en' => new DiffOpAdd('foo'))), $diff->getLabelsDiff());
$this->assertEquals(new Diff(array('bar' => new Diff(array('name' => new DiffOpAdd('baz'))))), $diff->getSiteLinkDiff());
}
示例11: getItem
protected static function getItem()
{
$item = new Item();
$fingerprint = $item->getFingerprint();
$fingerprint->setLabel('en', 'Venezuela');
$fingerprint->setDescription('en', 'a country');
$fingerprint->setAliasGroup('en', array('Bolivarian Republic of Venezuela'));
$siteLinks = $item->getSiteLinkList();
$siteLinks->addNewSiteLink('enwiki', 'Venezuela');
$siteLinks->addNewSiteLink('jawiki', 'ベネズエラ');
$siteLinks->addNewSiteLink('cawiki', 'Veneçuela');
return $item;
}
示例12: testAttemptSave
public function testAttemptSave()
{
$mockApiBase = $this->getMockApiBase();
$mockApiBase->expects($this->once())->method('isWriteMode')->will($this->returnValue(true));
$mockApiBase->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($this->newContext()));
$mockApiBase->expects($this->atLeastOnce())->method('extractRequestParams')->will($this->returnValue(array()));
$helper = new EntitySavingHelper($mockApiBase, $this->getMockErrorReporter(), $this->getMockSummaryFormatter(), $this->getMockEditEntityFactory(1));
$entity = new Item();
$entity->setId(new ItemId('Q444'));
$entity->getFingerprint()->setLabel('en', 'Foo');
$entity->getSiteLinkList()->addNewSiteLink('enwiki', 'APage');
$entity->getStatements()->addNewStatement(new PropertyNoValueSnak(new PropertyId('P8')));
$summary = 'A String Summary';
$flags = 0;
$status = $helper->attemptSaveEntity($entity, $summary, $flags);
$this->assertTrue($status->isGood());
}
示例13: getMockRepository
/**
* 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;
}
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:31,代码来源:EntityDataSerializationServiceTest.php
示例14: deserializationProvider
public function deserializationProvider()
{
$provider = array(array(new Item(), array('type' => 'item')));
$item = new Item(new ItemId('Q42'));
$provider[] = array($item, array('type' => 'item', 'id' => 'Q42'));
$item = new Item();
$item->getFingerprint()->setLabel('en', 'foo');
$provider[] = array($item, array('type' => 'item', 'labels' => array('en' => array('lang' => 'en', 'value' => 'foo'))));
$item = new Item();
$item->getFingerprint()->setDescription('en', 'foo');
$provider[] = array($item, array('type' => 'item', 'descriptions' => array('en' => array('lang' => 'en', 'value' => 'foo'))));
$item = new Item();
$item->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
$provider[] = array($item, array('type' => 'item', 'aliases' => array('en' => array('lang' => 'en', 'values' => array('foo', 'bar')))));
$item = new Item();
$item->getStatements()->addNewStatement(new PropertyNoValueSnak(42), null, null, 'test');
$provider[] = array($item, array('type' => 'item', 'claims' => array('P42' => array(array('mainsnak' => array('snaktype' => 'novalue', 'property' => 'P42'), 'type' => 'statement', 'rank' => 'normal')))));
$item = new Item();
$item->addSiteLink(new SiteLink('enwiki', 'Nyan Cat'));
$provider[] = array($item, array('type' => 'item', 'sitelinks' => array('enwiki' => array('site' => 'enwiki', 'title' => 'Nyan Cat', 'badges' => array()))));
return $provider;
}
示例15: execute
public function execute()
{
global $wgUser;
$user = $wgUser;
$store = WikibaseRepo::getDefaultInstance()->getEntityStore();
if (!defined('WB_VERSION')) {
$this->output("You need to have Wikibase enabled in order to use this maintenance script!\n\n");
exit;
}
$report = function ($message) {
echo $message . "\n";
};
$items = array('Q1' => 'Universe', 'Q2' => 'Earth', 'Q3' => 'Life', 'Q4' => 'Death', 'Q5' => 'Human', 'Q8' => 'Happiness', 'Q13' => 'Triskaidekaphobia', 'Q23' => 'George Washington', 'Q24' => 'Jack Bauer', 'Q42' => 'Douglas Adams', 'Q80' => 'Tim Berners-Lee', 'Q666' => 'Number of the Beast', 'Q1337' => 'Leet', 'Q1868' => 'Paul Otlet', 'Q1971' => 'Imagine (song)', 'Q2001' => 'Stanley Kubrick', 'Q2012' => 'Maya calendar', 'Q2013' => 'Wikidata');
$report('Starting import...');
foreach ($items as $id => $name) {
$report(" Importing {$name} as item {$id}...");
$item = new Item(new ItemId($id));
$item->getFingerprint()->setLabel('en', $name);
$item->getSiteLinkList()->addNewSiteLink('enwiki', $name);
$store->saveEntity($item, 'Import', $user, EDIT_NEW);
}
$report('Import completed.');
}