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


PHP WikibaseRepo::getDefaultInstance方法代码示例

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


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

示例1: getLanguageFallbackChain

 /**
  * Get the language fallback chain for current context.
  *
  * @since 0.4
  *
  * @return LanguageFallbackChain
  */
 public function getLanguageFallbackChain()
 {
     if ($this->languageFallbackChain === null) {
         $this->languageFallbackChain = WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory()->newFromContext($this->getContext());
     }
     return $this->languageFallbackChain;
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:14,代码来源:HistoryEntityAction.php

示例2: __construct

 /**
  * @since 0.4
  *
  * @param string $title The title of the special page
  * @param string $restriction The required user right, 'edit' per default.
  */
 public function __construct($title, $restriction = 'edit')
 {
     parent::__construct($title, $restriction);
     $settings = WikibaseRepo::getDefaultInstance()->getSettings();
     $this->rightsUrl = $settings->getSetting('dataRightsUrl');
     $this->rightsText = $settings->getSetting('dataRightsText');
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:13,代码来源:SpecialModifyEntity.php

示例3: testMovePrevention

 /**
  * Tests @see WikibaseItem::getIdForSiteLink
  */
 public function testMovePrevention()
 {
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $titleLookup = $wikibaseRepo->getEntityTitleLookup();
     // Moving a regular page into data NS onto an existing item
     $title = $this->itemTitle;
     $this->assertInstanceOf('Title', $title);
     // sanity check
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     $entityNamespaceLookup = $wikibaseRepo->getEntityNamespaceLookup();
     $itemNamespace = $entityNamespaceLookup->getEntityNamespace(CONTENT_MODEL_WIKIBASE_ITEM);
     // Moving a regular page into data NS to an invalid location
     // @todo: test other types of entities too!
     $title = Title::newFromText($this->page->getTitle()->getText(), $itemNamespace);
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     // Moving a regular page into data NS to an empty (but valid) location
     $title = $titleLookup->getTitleForId(new ItemId('Q42'));
     $this->assertFalse($this->page->getTitle()->moveTo($title) === true);
     // Moving item page out of data NS onto an existing page
     $title = $this->page->getTitle();
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item page out of data NS onto a non-existing page
     $title = Title::newFromText('wbmovetestitem');
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item to an invalid location in the data NS
     $title = Title::newFromText($this->page->getTitle()->getText(), $itemNamespace);
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
     // Moving item to an valid location in the data NS
     $title = $titleLookup->getTitleForId(new ItemId('Q42'));
     $this->assertFalse($this->itemTitle->moveTo($title) === true);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:34,代码来源:ItemMoveTest.php

示例4: testScript

 public function testScript()
 {
     $dumpScript = new DumpRdf();
     $mockRepo = new MockRepository();
     $mockEntityPerPage = new MockEntityPerPage();
     $snakList = new SnakList();
     $snakList->addSnak(new PropertySomeValueSnak(new PropertyId('P12')));
     $snakList->addSnak(new PropertyValueSnak(new PropertyId('P12'), new StringValue('stringVal')));
     /** @var Entity[] $testEntities */
     $testEntities = array(new Item(new ItemId('Q1')), new Property(new PropertyId('P1'), null, 'string'), new Property(new PropertyId('P12'), null, 'string', new StatementList(array(new Statement(new PropertySomeValueSnak(new PropertyId('P999')), null, null, 'GUID1')))), new Item(new ItemId('Q2'), new Fingerprint(new TermList(array(new Term('en', 'en-label'), new Term('de', 'de-label'))), new TermList(array(new Term('fr', 'en-desc'), new Term('de', 'de-desc'))), new AliasGroupList(array(new AliasGroup('en', array('ali1', 'ali2')), new AliasGroup('dv', array('ali11', 'ali22'))))), new SiteLinkList(array(new SiteLink('enwiki', 'Berlin'), new SiteLink('dewiki', 'England', array(new ItemId('Q1'))))), new StatementList(array(new Statement(new PropertySomeValueSnak(new PropertyId('P12')), null, null, 'GUID1'), new Statement(new PropertySomeValueSnak(new PropertyId('P12')), $snakList, new ReferenceList(array(new Reference(array(new PropertyValueSnak(new PropertyId('P12'), new StringValue('refSnakVal')), new PropertyNoValueSnak(new PropertyId('P12')))))), 'GUID2')))));
     foreach ($testEntities as $key => $testEntity) {
         $mockRepo->putEntity($testEntity, $key, '20000101000000');
         $mockEntityPerPage->addEntityPage($testEntity->getId(), $key);
     }
     // Note: We are testing with the actual RDF bindings, so we can check for actual RDF output.
     $rdfBuilder = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory();
     $dumpScript->setServices($mockEntityPerPage, new NullEntityPrefetcher(), MockSiteStore::newFromTestSites(), $this->getMockPropertyDataTypeLookup(), $rdfBuilder, $mockRepo, 'fooUri');
     $logFileName = tempnam(sys_get_temp_dir(), "Wikibase-DumpRdfTest");
     $outFileName = tempnam(sys_get_temp_dir(), "Wikibase-DumpRdfTest");
     $dumpScript->loadParamsAndArgs(null, array('log' => $logFileName, 'output' => $outFileName, 'format' => 'n-triples'));
     $dumpScript->execute();
     $expectedLog = file_get_contents(__DIR__ . '/../data/maintenance/dumpRdf-log.txt');
     $expectedOut = file_get_contents(__DIR__ . '/../data/maintenance/dumpRdf-out.txt');
     $actualOut = file_get_contents($outFileName);
     $actualOut = preg_replace('/<http:\\/\\/wikiba.se\\/ontology-beta#Dump> <http:\\/\\/schema.org\\/dateModified> "[^"]+"/', "<http://wikiba.se/ontology-beta#Dump> <http://schema.org/dateModified> \"2015-01-01T00:00:00Z\"", $actualOut);
     $this->assertEquals($this->fixLineEndings($expectedLog), $this->fixLineEndings(file_get_contents($logFileName)));
     $this->assertEquals($this->fixLineEndings($expectedOut), $this->fixLineEndings($actualOut));
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:28,代码来源:dumpRdfTest.php

示例5: __construct

 /**
  * @param ApiMain $mainModule
  * @param string $moduleName
  * @param string $modulePrefix
  *
  * @see ApiBase::__construct
  */
 public function __construct(ApiMain $mainModule, $moduleName, $modulePrefix = '')
 {
     parent::__construct($mainModule, $moduleName, $modulePrefix);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $apiHelperFactory = $wikibaseRepo->getApiHelperFactory($this->getContext());
     $this->setServices($wikibaseRepo->getDataTypeFactory(), $wikibaseRepo->getValueParserFactory(), $wikibaseRepo->getDataTypeValidatorFactory(), $wikibaseRepo->getExceptionLocalizer(), $wikibaseRepo->getValidatorErrorLocalizer(), $apiHelperFactory->getErrorReporter($this));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:14,代码来源:ParseValue.php

示例6: __construct

 public function __construct()
 {
     parent::__construct('SetLabelDescriptionAliases', 'edit');
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $this->changeOpFactory = $wikibaseRepo->getChangeOpFactoryProvider()->getFingerprintChangeOpFactory();
     $this->termsLanguages = $wikibaseRepo->getTermsLanguages();
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:7,代码来源:SpecialSetLabelDescriptionAliases.php

示例7: __construct

 /**
  * @see SpecialWikibasePage::__construct
  */
 public function __construct()
 {
     parent::__construct('GoToLinkedPage', '', true);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $this->initServices($wikibaseRepo->getSiteStore(), $wikibaseRepo->getStore()->newSiteLinkStore(), $wikibaseRepo->getStore()->getEntityRedirectLookup(), $wikibaseRepo->getEntityIdParser(), $wikibaseRepo->getStore()->getEntityLookup());
     $this->errorMessageKey = null;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:10,代码来源:SpecialGoToLinkedPage.php

示例8: addItems

 /**
  * @return Item[]
  */
 private function addItems()
 {
     $user = $this->getUser();
     $labels = array('New York City', 'Tokyo', 'Jakarta', 'Nairobi', 'Rome', 'Cairo', 'Santiago', 'Sydney', 'Toronto', 'Berlin');
     /** @var Item[] $items */
     $items = array();
     $prefix = get_class($this) . '/';
     $store = WikibaseRepo::getDefaultInstance()->getEntityStore();
     foreach ($labels as $label) {
         $item = new Item();
         $item->setLabel('en', $prefix . $label);
         $rev = $store->saveEntity($item, "added an item", $user, EDIT_NEW);
         $items[] = $rev->getEntity();
     }
     // add another berlin (so we have a valid id), then turn it into a redirect
     $item = new Item();
     $item->setLabel('en', $prefix . 'Berlin2');
     $rev = $store->saveEntity($item, "added an item", $user, EDIT_NEW);
     $items[] = $rev->getEntity();
     $items = array_reverse($items);
     $berlin2 = $items[0]->getId();
     $berlin1 = $items[1]->getId();
     $redirect = new EntityRedirect($berlin2, $berlin1);
     $store->saveRedirect($redirect, "created redirect", $user, EDIT_UPDATE);
     return $items;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:29,代码来源:EntityPerPageBuilderTest.php

示例9: getChangeNotifier

 private function getChangeNotifier($expectNotifications = 1)
 {
     $changeTransmitter = $this->getMock('Wikibase\\Repo\\Notifications\\ChangeTransmitter');
     $changeTransmitter->expects($this->exactly($expectNotifications))->method('transmitChange');
     $notifier = new ChangeNotifier(WikibaseRepo::getDefaultInstance()->getEntityChangeFactory(), array($changeTransmitter));
     return $notifier;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:ChangeNotifierTest.php

示例10: __construct

 /**
  * @param ApiMain $mainModule
  * @param string $moduleName
  * @param string $modulePrefix
  *
  * @see ApiBase::__construct
  */
 public function __construct(ApiMain $mainModule, $moduleName, $modulePrefix = '')
 {
     parent::__construct($mainModule, $moduleName, $modulePrefix);
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $apiHelperFactory = $wikibaseRepo->getApiHelperFactory($this->getContext());
     $this->setServices($wikibaseRepo->getEntityIdParser(), $apiHelperFactory->getErrorReporter($this), $apiHelperFactory->getResultBuilder($this), new ItemMergeInteractor($wikibaseRepo->getChangeOpFactoryProvider()->getMergeChangeOpFactory(), $wikibaseRepo->getEntityRevisionLookup('uncached'), $wikibaseRepo->getEntityStore(), $wikibaseRepo->getEntityPermissionChecker(), $wikibaseRepo->getSummaryFormatter(), $this->getUser(), $wikibaseRepo->newRedirectCreationInteractor($this->getUser(), $this->getContext())));
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:14,代码来源:MergeItems.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $sitesTable = WikibaseRepo::getDefaultInstance()->getSiteStore();
     $sitesTable->clear();
     $sitesTable->saveSites(TestSites::getSites());
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:7,代码来源:IntegrationApiTest.php

示例12: newRedirect

 /**
  * @param ItemId $itemId
  * @param ItemId $targetId
  *
  * @return ItemContent
  */
 private function newRedirect(ItemId $itemId, ItemId $targetId)
 {
     // FIXME: Use the respective EntityHandler instead of going via the global title lookup!
     $titleLookup = WikibaseRepo::getDefaultInstance()->getEntityTitleLookup();
     $title = $titleLookup->getTitleForId($targetId);
     return ItemContent::newFromRedirect(new EntityRedirect($itemId, $targetId), $title);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:13,代码来源:ItemContentTest.php

示例13: setup

 public function setup()
 {
     parent::setup();
     if (!isset(self::$hasSetup)) {
         $wikibaseRepo = WikibaseRepo::getDefaultInstance();
         $store = $wikibaseRepo->getEntityStore();
         $prop = Property::newFromType('string');
         $store->saveEntity($prop, 'EditEntityTestP56', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%P56%'] = $prop->getId()->getSerialization();
         self::$idMap['%StringProp%'] = $prop->getId()->getSerialization();
         $prop = Property::newFromType('string');
         $store->saveEntity($prop, 'EditEntityTestP72', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%P72%'] = $prop->getId()->getSerialization();
         $this->initTestEntities(array('Berlin'), self::$idMap);
         self::$idMap['%Berlin%'] = EntityTestHelper::getId('Berlin');
         $p56 = self::$idMap['%P56%'];
         $berlinData = EntityTestHelper::getEntityOutput('Berlin');
         self::$idMap['%BerlinP56%'] = $berlinData['claims'][$p56][0]['id'];
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ42', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q42%'] = $badge->getId()->getSerialization();
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ149', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q149%'] = $badge->getId()->getSerialization();
         $badge = new Item();
         $store->saveEntity($badge, 'EditEntityTestQ32', $GLOBALS['wgUser'], EDIT_NEW);
         self::$idMap['%Q32%'] = $badge->getId()->getSerialization();
         $wikibaseRepo->getSettings()->setSetting('badgeItems', array(self::$idMap['%Q42%'] => '', self::$idMap['%Q149%'] => '', 'Q99999' => ''));
     }
     self::$hasSetup = true;
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:31,代码来源:EditEntityTest.php

示例14: newFromGlobalState

 /**
  * @return OutputPageBeforeHTMLHookHandler
  */
 public static function newFromGlobalState()
 {
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $entityIdParser = $wikibaseRepo->getEntityIdParser();
     $entityContentFactory = $wikibaseRepo->getEntityContentFactory();
     return new self(TemplateFactory::getDefaultInstance(), new BabelUserLanguageLookup(), $wikibaseRepo->getTermsLanguages(), $entityIdParser, $wikibaseRepo->getEntityRevisionLookup(), new LanguageNameLookup(), $entityContentFactory);
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:10,代码来源:OutputPageBeforeHTMLHookHandler.php

示例15: newHolder

 /**
  * @param Entity $entity
  * @param string|null $expectedEntityType
  * @param EntityId|null $expectedEntityId
  *
  * @return EntityHolder
  */
 private function newHolder(Entity $entity, $expectedEntityType = null, EntityId $expectedEntityId = null)
 {
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $codec = new EntityContentDataCodec(new BasicEntityIdParser(), $wikibaseRepo->getInternalEntitySerializer(), $wikibaseRepo->getInternalEntityDeserializer());
     $blob = $codec->encodeEntity($entity, CONTENT_FORMAT_JSON);
     return new DeferredDecodingEntityHolder($codec, $blob, CONTENT_FORMAT_JSON, $expectedEntityType ?: $entity->getType(), $expectedEntityId);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:14,代码来源:DeferredDecodingEntityHolderTest.php


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