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


PHP Entity\Item类代码示例

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


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

示例1: itemProvider

 public function itemProvider()
 {
     $emptyItem = new Item(new ItemId('Q1'));
     $item = new Item(new ItemId('Q11'));
     $item->setDescription('en', 'ohi there');
     $item->setLabel('de', 'o_O');
     $item->setAliases('nl', array('foo', 'bar'));
     $item2 = new Item(new ItemId('Q12'));
     $item2->setLabel('de', 'o_O');
     $item2->setLabel('en', 'O_o');
     $item2->setAliases('nl', array('daaaah'));
     $redirect = new EntityRedirect(new ItemId('Q11'), new ItemId('Q21'));
     $redirect2 = new EntityRedirect(new ItemId('Q11'), new ItemId('Q22'));
     $insTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>bar</ins>' => array('tag' => 'ins', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <ins>ohi there</ins>' => array('tag' => 'ins', 'content' => 'ohi there'));
     $delTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there'));
     $changeTags = array('has <td>label / en</td>' => array('tag' => 'td', 'content' => 'label / en'), 'has <ins>O_o</ins>' => array('tag' => 'ins', 'content' => 'O_o'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>daaaah</ins>' => array('tag' => 'ins', 'content' => 'daaaah'), 'has <td>aliases / nl / 1</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 1'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 2</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 2'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there'));
     $fromRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21'));
     $toRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <ins>Q21</ins>' => array('tag' => 'ins', 'content' => 'Q21'));
     $changeRedirTags = array('has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21'), 'has <ins>Q22</del>' => array('tag' => 'ins', 'content' => 'Q22'));
     $empty = ItemContent::newFromItem($emptyItem);
     $itemContent = ItemContent::newFromItem($item);
     $itemContent2 = ItemContent::newFromItem($item2);
     $redirectContent = ItemContent::newFromRedirect($redirect, Title::newFromText($redirect->getEntityId()->getSerialization()));
     $redirectContent2 = ItemContent::newFromRedirect($redirect2, Title::newFromText($redirect2->getEntityId()->getSerialization()));
     return array('empty' => array($empty, $empty, array('empty' => '/^$/')), 'same' => array($itemContent, $itemContent, array('empty' => '/^$/')), 'from emtpy' => array($empty, $itemContent, $insTags), 'to empty' => array($itemContent, $empty, $delTags), 'changed' => array($itemContent, $itemContent2, $changeTags), 'to redirect' => array($itemContent, $redirectContent, $toRedirTags), 'from redirect' => array($redirectContent, $itemContent, $fromRedirTags), 'redirect changed' => array($redirectContent, $redirectContent2, $changeRedirTags));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:26,代码来源:EntityContentDiffViewTest.php

示例2: getBadgeItem

 private function getBadgeItem()
 {
     $item = new Item(new ItemId('Q17'));
     $item->setLabel('de', 'exzellent');
     $item->setLabel('en', 'featured');
     return $item;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:SidebarHookHandlersTest.php

示例3: 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;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:31,代码来源:ChangeRunCoalescerTest.php

示例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);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:26,代码来源:FormatSnakValueTest.php

示例5: testRebuildSearchKey

 /**
  * @dataProvider termProvider
  */
 public function testRebuildSearchKey($languageCode, $termText, $searchText, $matches)
 {
     /* @var TermSqlIndex $termCache */
     $termCache = WikibaseRepo::getDefaultInstance()->getStore()->getTermIndex();
     // make term in item
     $item = new Item(new ItemId('Q42'));
     $item->setLabel($languageCode, $termText);
     // save term
     $termCache->clear();
     $termCache->saveTermsOfEntity($item);
     // remove search key
     $dbw = wfGetDB(DB_MASTER);
     $dbw->update($termCache->getTableName(), array('term_search_key' => ''), array(), __METHOD__);
     // rebuild search key
     $builder = new TermSearchKeyBuilder($termCache);
     $builder->setRebuildAll(true);
     $builder->rebuildSearchKey();
     // remove search key
     $term = new TermIndexEntry();
     $term->setLanguage($languageCode);
     $term->setText($searchText);
     $options = array('caseSensitive' => false);
     $obtainedTerms = $termCache->getMatchingTerms(array($term), TermIndexEntry::TYPE_LABEL, Item::ENTITY_TYPE, $options);
     $this->assertEquals($matches ? 1 : 0, count($obtainedTerms));
     if ($matches) {
         $obtainedTerm = array_shift($obtainedTerms);
         $this->assertEquals($termText, $obtainedTerm->getText());
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:32,代码来源:TermSearchKeyBuilderTest.php

示例6: entityProvider

 public function entityProvider()
 {
     $empty = new Item(new ItemId('Q1'));
     $simple = new Item(new ItemId('Q1'));
     $simple->setLabel('en', 'Test');
     return array('Property' => array(Property::newFromType('string'), null), 'empty' => array($empty, null), 'empty json' => array($empty, CONTENT_FORMAT_JSON), 'simple' => array($simple, null), 'simple json' => array($simple, CONTENT_FORMAT_JSON), 'simple php' => array($simple, CONTENT_FORMAT_SERIALIZED));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:EntityContentDataCodecTest.php

示例7: testGivenEmptyDiffItemRemainsUnchanged

 /**
  * @dataProvider itemProvider
  */
 public function testGivenEmptyDiffItemRemainsUnchanged(Item $item)
 {
     $patcher = new EntityPatcher();
     $patchedEntity = $item->copy();
     $patcher->patchEntity($patchedEntity, new ItemDiff());
     $this->assertEquals($item, $patchedEntity);
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:10,代码来源:EntityPatcherTest.php

示例8: getEntityRevisions

 /**
  * @return EntityRevision[]
  */
 public static function getEntityRevisions()
 {
     $item = new Item(new ItemId('Q42'));
     $item->setLabel('en', 'Raarrr!');
     $itemRev = new EntityRevision($item, 4242, '20131211100908');
     return array($itemRev);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:10,代码来源:EntityDataTestProvider.php

示例9: getKnownEntities

 /**
  * @return EntityDocument[]
  */
 protected function getKnownEntities()
 {
     $q1 = new Item(new ItemId('Q1'));
     $q1->setLabel('en', 'label:Q1/en');
     $q1->setLabel('de', 'label:Q1/de');
     $q1->setDescription('en', 'description:Q1/en');
     $q1->setDescription('de', 'description:Q1/de');
     $q1->setAliases('en', array('alias:Q1/en#1'));
     $q1->setAliases('de', array('alias:Q1/de#1', 'alias:Q1/de#2'));
     $q2 = new Item(new ItemId('Q2'));
     $q2->setLabel('en', 'label:Q2/en');
     $q2->setLabel('de', 'label:Q2/de');
     $q2->setAliases('en', array('alias:Q2/en#1'));
     $q2->setAliases('de', array('alias:Q2/de#1', 'alias:Q2/de#2'));
     $p2 = Property::newFromType('string');
     $p2->setId(new PropertyId('P2'));
     $p2->setLabel('en', 'label:P2/en');
     $p2->setLabel('de', 'label:P2/de');
     $p2->setDescription('en', 'description:P2/en');
     $p2->setDescription('de', 'description:P2/de');
     $p2->setAliases('en', array('alias:P2/en#1'));
     $p2->setAliases('de', array('alias:P2/de#1', 'alias:P2/de#2'));
     $p3 = Property::newFromType('string');
     $p3->setId(new PropertyId('P3'));
     $p3->setLabel('en', 'label:P3/en');
     $p3->setLabel('de', 'label:P3/de');
     $p3->setDescription('en', 'description:P3/en');
     $p3->setDescription('de', 'description:P3/de');
     return array($q1, $q2, $p2, $p3);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:33,代码来源:EntityInfoBuilderTest.php

示例10: 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

示例11: 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;
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:16,代码来源:UpdateRepoOnMoveJob.php

示例12: 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;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:8,代码来源:ItemViewTest.php

示例13: 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");
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:14,代码来源:ItemSearchTextGenerator.php

示例14: 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);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:9,代码来源:ItemSearchTextGeneratorTest.php

示例15: addStatements

 private function addStatements(Item $item)
 {
     $statement = new Statement(new PropertyValueSnak(42, new StringValue('kittens')));
     $statement->setGuid('first guid');
     $item->getStatements()->addStatement($statement);
     $statement = new Statement(new PropertyNoValueSnak(23));
     $statement->setGuid('second guid');
     $item->getStatements()->addStatement($statement);
 }
开发者ID:queryr,项目名称:serialization,代码行数:9,代码来源:SimpleItemBuilderTest.php


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