当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::getId方法代码示例

本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getId方法的具体用法?PHP Item::getId怎么用?PHP Item::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wikibase\DataModel\Entity\Item的用法示例。


在下文中一共展示了Item::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
     }
 }
开发者ID:JeroenDeDauw,项目名称:QueryrAPI,代码行数:7,代码来源:SimpleItemBuilder.php

示例2: getEntityIdentifierFromTarget

 /**
  * @param EntityId|Item|Property $target
  *
  * @throws UnexpectedValueException
  * @return EntityId|SiteLink
  *
  * @todo Fix duplicated code
  */
 private function getEntityIdentifierFromTarget($target)
 {
     if ($target instanceof Item || $target instanceof Property) {
         return $target->getId();
     } else {
         return $target;
     }
 }
开发者ID:hakanozdemir,项目名称:wikibase-api,代码行数:16,代码来源:LabelSetter.php

示例3: testGetEntity

 /**
  * @dataProvider getEntityProvider
  */
 public function testGetEntity(array $expected, Item $item, EntityLookup $entityLookup)
 {
     $prefixedId = $item->getId()->getSerialization();
     $entityAccessor = $this->getEntityAccessor($entityLookup);
     $entityArr = $entityAccessor->getEntity($prefixedId);
     $actual = is_array($entityArr) ? $entityArr : array();
     $this->assertSameSize($expected, $actual);
     foreach ($expected as $expectedKey) {
         $this->assertArrayHasKey($expectedKey, $actual);
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:14,代码来源:EntityAccessorTest.php

示例4: invalidArgumentProvider

 public function invalidArgumentProvider()
 {
     $item = new Item(new ItemId('Q42'));
     $guidGenerator = new GuidGenerator();
     $validGuid = $guidGenerator->newGuid($item->getId());
     $validRank = 1;
     $args = array();
     $args[] = array(123, $validRank);
     $args[] = array($validGuid, ':-)');
     return $args;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:11,代码来源:ChangeOpStatementRankTest.php

示例5: addStatements

 /**
  * @param Item $item
  * @param PropertyId $propertyId
  */
 private function addStatements(Item $item, PropertyId $propertyId)
 {
     if (!$item->getId()) {
         $this->save($item);
     }
     /** @var Statement[] $statements */
     $statements[0] = new Statement(new PropertyNoValueSnak($propertyId));
     $statements[1] = new Statement(new PropertyNoValueSnak($propertyId));
     $statements[2] = new Statement(new PropertySomeValueSnak($propertyId));
     $statements[3] = new Statement(new PropertyValueSnak($propertyId, new StringValue('o_O')));
     foreach ($statements as $key => $statement) {
         $statement->setGuid($item->getId()->getSerialization() . '$D8404CDA-56A1-4334-AF13-A3290BCD9CL' . $key);
         $item->getStatements()->addStatement($statement);
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:19,代码来源:GetClaimsTest.php

示例6: makeChangeOpsMerge

 protected function makeChangeOpsMerge(Item $fromItem, Item $toItem, array $ignoreConflicts = array(), $siteLookup = null)
 {
     if ($siteLookup === null) {
         $siteLookup = MockSiteStore::newFromTestSites();
     }
     // A validator which makes sure that no site link is for page 'DUPE'
     $siteLinkUniquenessValidator = $this->getMock('Wikibase\\Repo\\Validators\\EntityValidator');
     $siteLinkUniquenessValidator->expects($this->any())->method('validateEntity')->will($this->returnCallback(function (Item $item) {
         $siteLinks = $item->getSiteLinkList();
         foreach ($siteLinks as $siteLink) {
             if ($siteLink->getPageName() === 'DUPE') {
                 return Result::newError(array(Error::newError('SiteLink conflict')));
             }
         }
         return Result::newSuccess();
     }));
     $constraintProvider = $this->getMockBuilder('Wikibase\\Repo\\Validators\\EntityConstraintProvider')->disableOriginalConstructor()->getMock();
     $constraintProvider->expects($this->any())->method('getUpdateValidators')->will($this->returnValue(array($siteLinkUniquenessValidator)));
     $changeOpFactoryProvider = new ChangeOpFactoryProvider($constraintProvider, $this->mockProvider->getMockGuidGenerator(), $this->mockProvider->getMockGuidValidator(), $this->mockProvider->getMockGuidParser($toItem->getId()), $this->mockProvider->getMockSnakValidator(), $this->mockProvider->getMockTermValidatorFactory(), $siteLookup);
     return new ChangeOpsMerge($fromItem, $toItem, $ignoreConflicts, $constraintProvider, $changeOpFactoryProvider, $siteLookup);
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:21,代码来源:ChangeOpsMergeTest.php

示例7: generateStatementsChangeOps

 private function generateStatementsChangeOps()
 {
     if (!in_array('statement', $this->ignoreConflicts)) {
         foreach ($this->toItem->getStatements()->toArray() as $toStatement) {
             $this->checkIsLink($toStatement, $this->fromItem->getId());
         }
     }
     foreach ($this->fromItem->getStatements()->toArray() as $fromStatement) {
         if (!in_array('statement', $this->ignoreConflicts)) {
             $this->checkIsLink($fromStatement, $this->toItem->getId());
         }
         $this->fromChangeOps->add($this->getStatementChangeOpFactory()->newRemoveStatementOp($fromStatement->getGuid()));
         $toStatement = clone $fromStatement;
         $toStatement->setGuid(null);
         $toMergeToStatement = $this->findEquivalentStatement($toStatement);
         if ($toMergeToStatement) {
             $this->generateReferencesChangeOps($toStatement, $toMergeToStatement);
         } else {
             $this->toChangeOps->add($this->getStatementChangeOpFactory()->newSetStatementOp($toStatement));
         }
     }
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:22,代码来源:ChangeOpsMerge.php

示例8: getConflictsForItem

 /**
  * @see SiteLinkConflictLookup::getConflictsForItem
  *
  * @param Item $item
  * @param DatabaseBase|null $db
  *
  * @return array[]
  */
 public function getConflictsForItem(Item $item, DatabaseBase $db = null)
 {
     $siteLinks = $item->getSiteLinkList();
     if ($siteLinks->isEmpty()) {
         return array();
     }
     if ($db) {
         $dbr = $db;
     } else {
         $dbr = $this->getConnection(DB_SLAVE);
     }
     $anyOfTheLinks = '';
     /** @var SiteLink $siteLink */
     foreach ($siteLinks as $siteLink) {
         if ($anyOfTheLinks !== '') {
             $anyOfTheLinks .= "\nOR ";
         }
         $anyOfTheLinks .= '(';
         $anyOfTheLinks .= 'ips_site_id=' . $dbr->addQuotes($siteLink->getSiteId());
         $anyOfTheLinks .= ' AND ';
         $anyOfTheLinks .= 'ips_site_page=' . $dbr->addQuotes($siteLink->getPageName());
         $anyOfTheLinks .= ')';
     }
     // TODO: $anyOfTheLinks might get very large and hit some size limit imposed
     //       by the database. We could chop it up of we know that size limit.
     //       For MySQL, it's select @@max_allowed_packet.
     $conflictingLinks = $dbr->select('wb_items_per_site', array('ips_site_id', 'ips_site_page', 'ips_item_id'), "({$anyOfTheLinks}) AND ips_item_id != " . (int) $item->getId()->getNumericId(), __METHOD__);
     $conflicts = array();
     foreach ($conflictingLinks as $link) {
         $conflicts[] = array('siteId' => $link->ips_site_id, 'itemId' => (int) $link->ips_item_id, 'sitePage' => $link->ips_site_page);
     }
     if (!$db) {
         $this->releaseConnection($dbr);
     }
     return $conflicts;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:44,代码来源:SqlSiteLinkConflictLookup.php

示例9: addSiteLinks

 /**
  * Adds the site links of the given item to the RDF graph.
  *
  * @param Item $item
  */
 public function addSiteLinks(Item $item)
 {
     $entityLName = $this->vocabulary->getEntityLName($item->getId());
     /** @var SiteLink $siteLink */
     foreach ($item->getSiteLinkList() as $siteLink) {
         if (!$this->isSiteIncluded($siteLink->getSiteId())) {
             continue;
         }
         // FIXME: we should check the site exists using hasGlobalId here before asuming it does
         $site = $this->siteLookup->getSite($siteLink->getSiteId());
         // XXX: ideally, we'd use https if the target site supports it.
         $baseUrl = str_replace('$1', rawurlencode($siteLink->getPageName()), $site->getLinkPath());
         // $site->getPageUrl( $siteLink->getPageName() );
         if (!parse_url($baseUrl, PHP_URL_SCHEME)) {
             $url = "http:" . $baseUrl;
         } else {
             $url = $baseUrl;
         }
         $this->writer->about($url)->a(RdfVocabulary::NS_SCHEMA_ORG, 'Article')->say(RdfVocabulary::NS_SCHEMA_ORG, 'about')->is(RdfVocabulary::NS_ENTITY, $entityLName)->say(RdfVocabulary::NS_SCHEMA_ORG, 'inLanguage')->text($this->vocabulary->getCanonicalLanguageCode($site->getLanguageCode()));
         foreach ($siteLink->getBadges() as $badge) {
             $this->writer->say(RdfVocabulary::NS_ONTOLOGY, 'badge')->is(RdfVocabulary::NS_ENTITY, $this->vocabulary->getEntityLName($badge));
         }
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:29,代码来源:SiteLinksRdfBuilder.php

示例10: attemptSaveMerge

 /**
  * @param Item $fromItem
  * @param Item $toItem
  * @param string|null $summary
  * @param bool $bot
  *
  * @return array A list of exactly two EntityRevision objects. The first one represents the
  *  modified source item, the second one represents the modified target item.
  */
 private function attemptSaveMerge(Item $fromItem, Item $toItem, $summary, $bot)
 {
     $toSummary = $this->getSummary('to', $toItem->getId(), $summary);
     $fromRev = $this->saveEntity($fromItem, $toSummary, $bot);
     $fromSummary = $this->getSummary('from', $fromItem->getId(), $summary);
     $toRev = $this->saveEntity($toItem, $fromSummary, $bot);
     return array($fromRev, $toRev);
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:17,代码来源:ItemMergeInteractor.php

示例11: newItemWithClaim

 private function newItemWithClaim($snak)
 {
     $item = new Item(new ItemId('Q123'));
     $item->getStatements()->addNewStatement($snak, null, null, $item->getId()->getSerialization() . '$D8494TYA-25E4-4334-AG03-A3290BCT9CQP');
     return $item;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:6,代码来源:ChangeOpReferenceTest.php

示例12: testClear

 /**
  * @depends testSaveLinksOfItem
  * @dataProvider itemProvider
  */
 public function testClear(Item $item)
 {
     $this->assertTrue($this->siteLinkTable->clear() !== false);
     $this->assertEmpty($this->siteLinkTable->getSiteLinksForItem($item->getId()));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:9,代码来源:SiteLinkTableTest.php

示例13: getHtmlForSiteLinks

 /**
  * Builds and returns the HTML representing a WikibaseEntity's site-links.
  *
  * @since 0.1
  *
  * @param Item $item the entity to render
  *
  * @return string HTML
  */
 protected function getHtmlForSiteLinks(Item $item)
 {
     return $this->siteLinksView->getHtml($item->getSiteLinks(), $item->getId(), $this->siteLinkGroups);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:13,代码来源:ItemView.php

示例14: saveLinksOfItem

 /**
  * @see SiteLinkStore::saveLinksOfItem
  *
  * @param Item $item
  *
  * @return bool
  */
 public function saveLinksOfItem(Item $item)
 {
     $itemId = $item->getId();
     $this->deleteLinksOfItem($itemId);
     foreach ($item->getSiteLinks() as $siteLink) {
         $this->indexByLink($itemId, $siteLink);
         $this->indexByItemId($itemId, $siteLink);
     }
     return true;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:17,代码来源:HashSiteLinkStore.php

示例15: addIdToSerialization

 private function addIdToSerialization(Item $item, array &$serialization)
 {
     $id = $item->getId();
     if ($id !== null) {
         $serialization['id'] = $id->getSerialization();
     }
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:7,代码来源:ItemSerializer.php


注:本文中的Wikibase\DataModel\Entity\Item::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。