本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::getSiteLinkList方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getSiteLinkList方法的具体用法?PHP Item::getSiteLinkList怎么用?PHP Item::getSiteLinkList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikibase\DataModel\Entity\Item
的用法示例。
在下文中一共展示了Item::getSiteLinkList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIdLinkForLanguage
private function addIdLinkForLanguage($languageCode)
{
$links = $this->item->getSiteLinkList();
if ($links->hasLinkWithSiteId($languageCode . 'wiki')) {
$this->simpleItem->ids[$languageCode . '_wikipedia'] = $links->getBySiteId($languageCode . 'wiki')->getPageName();
}
}
示例2: getSiteLinkLookup
/**
* @param ItemId[] $links
*
* @return SiteLinkLookup
*/
private function getSiteLinkLookup(array $links)
{
$siteLinkLookup = new HashSiteLinkStore();
foreach ($links as $pageId => $itemId) {
$pageName = self::PAGE_NAME_PREFIX . $pageId;
$item = new Item($itemId);
$item->getSiteLinkList()->addNewSiteLink('testwiki', $pageName);
$item->getSiteLinkList()->addNewSiteLink('badwiki', $pageName);
$item->getSiteLinkList()->addNewSiteLink('sadwiki', 'Other stuff');
$siteLinkLookup->saveLinksOfItem($item);
}
return $siteLinkLookup;
}
示例3: addWikipediaHtmlUrl
private function addWikipediaHtmlUrl()
{
$wikiId = $this->getWikiId($this->languageCode);
if ($this->item->getSiteLinkList()->hasLinkWithSiteId($wikiId)) {
$this->simpleItem->wikipediaHtmlUrl = $this->urlBuilder->getSiteLinkBasedRerirectUrl($wikiId, $this->item->getId());
}
}
示例4: getEntityRevisionLookup
/**
* @return EntityRevisionLookup
*/
private function getEntityRevisionLookup()
{
$repo = new MockRepository();
$offsets = array('Q1' => 1100, 'Q2' => 1200);
foreach ($offsets as $qid => $offset) {
// entity 1, revision 1111
$entity1 = new Item(new ItemId($qid));
$entity1->setLabel('en', 'ORIGINAL');
$entity1->getSiteLinkList()->addNewSiteLink('enwiki', 'Original');
$repo->putEntity($entity1, $offset + 11);
// entity 1, revision 1112
$entity1->setLabel('de', 'HINZUGEFÜGT');
$repo->putEntity($entity1, $offset + 12);
// entity 1, revision 1113
$entity1->setLabel('nl', 'Addiert');
$repo->putEntity($entity1, $offset + 13);
// entity 1, revision 1114
$entity1->getSiteLinkList()->addNewSiteLink('dewiki', 'Testen');
$repo->putEntity($entity1, $offset + 14);
// entity 1, revision 1117
$entity1->getSiteLinkList()->setSiteLink(new SiteLink('enwiki', 'Spam', array(new ItemId('Q12345'))));
$repo->putEntity($entity1, $offset + 17);
// entity 1, revision 1118
$entity1->getSiteLinkList()->setSiteLink(new SiteLink('enwiki', 'Spam', array(new ItemId('Q54321'))));
$repo->putEntity($entity1, $offset + 18);
}
return $repo;
}
示例5: getSiteLink
/**
* Get a SiteLink for a specific item and site
*
* @param Item $item
* @param string $globalId
*
* @return SiteLink|null
*/
private function getSiteLink($item, $globalId)
{
try {
return $item->getSiteLinkList()->getBySiteId($globalId);
} catch (OutOfBoundsException $e) {
return null;
}
}
示例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: 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);
}
示例8: testGivenEmptyDiff_itemIsReturnedAsIs
public function testGivenEmptyDiff_itemIsReturnedAsIs()
{
$item = new Item();
$item->getFingerprint()->setLabel('en', 'foo');
$item->getSiteLinkList()->addNewSiteLink('enwiki', 'bar');
$patchedItem = $this->getPatchedItem($item, new ItemDiff());
$this->assertInstanceOf('Wikibase\\DataModel\\Entity\\Item', $patchedItem);
$this->assertTrue($item->equals($patchedItem));
}
示例9: 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");
}
示例10: testLinkSitelinks
/**
* @depends testCreateItem
* @depends testSetSitelink
*/
public function testLinkSitelinks()
{
$factory = $factory = TestEnvironment::newDefault()->getFactory();
$enwikiLondon = new SiteLink('enwiki', 'London');
$dewikiBerlin = new Sitelink('dewiki', 'Berlin');
$r = $factory->newSiteLinkLinker()->link($enwikiLondon, $dewikiBerlin);
$this->assertTrue($r);
self::$localItem->getSiteLinkList()->addSiteLink($dewikiBerlin);
}
示例11: 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());
}
示例12: generateSitelinksChangeOps
private function generateSitelinksChangeOps()
{
foreach ($this->fromItem->getSiteLinkList()->toArray() as $fromSiteLink) {
$siteId = $fromSiteLink->getSiteId();
if (!$this->toItem->getSiteLinkList()->hasLinkWithSiteId($siteId)) {
$this->generateSitelinksChangeOpsWithNoConflict($fromSiteLink);
} else {
$this->generateSitelinksChangeOpsWithConflict($fromSiteLink);
}
}
}
示例13: getLinksInDiffFormat
private function getLinksInDiffFormat(Item $item)
{
$links = array();
/**
* @var SiteLink $siteLink
*/
foreach ($item->getSiteLinkList() as $siteLink) {
$links[$siteLink->getSiteId()] = array('name' => $siteLink->getPageName(), 'badges' => array_map(function (ItemId $id) {
return $id->getSerialization();
}, $siteLink->getBadges()));
}
return $links;
}
示例14: makeEntity
/**
* @param EntityId $id
*
* @throws InvalidArgumentException
* @return Item|Property
*/
protected function makeEntity(EntityId $id)
{
if ($id instanceof ItemId) {
$entity = new Item($id);
$entity->getSiteLinkList()->addNewSiteLink('test', 'Foo');
} elseif ($id instanceof PropertyId) {
$entity = new Property($id, null, 'wibblywobbly');
} else {
throw new InvalidArgumentException('Unsupported entity type ' . $id->getEntityType());
}
$entity->setLabel('en', 'label:' . $id->getSerialization());
return $entity;
}
示例15: testValidateEntity_conflict
public function testValidateEntity_conflict()
{
$badEntity = new Item(new ItemId('Q7'));
$badEntity->getSiteLinkList()->addNewSiteLink('testwiki', 'DUPE');
$siteLinkConflictLookup = $this->getMockSiteLinkConflictLookup();
$validator = new SiteLinkUniquenessValidator($siteLinkConflictLookup);
$result = $validator->validateEntity($badEntity);
$this->assertFalse($result->isValid(), 'isValid');
$errors = $result->getErrors();
$this->assertEquals('sitelink-conflict', $errors[0]->getCode());
$this->assertInstanceOf('Wikibase\\Repo\\Validators\\UniquenessViolation', $errors[0]);
//NOTE: ChangeOpTestMockProvider::getSiteLinkConflictsForItem() uses 'Q666' as
// the conflicting item for all site links with the name 'DUPE'.
$this->assertEquals('Q666', $errors[0]->getConflictingEntity());
}