本文整理汇总了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;
}
示例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');
}
示例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);
}
示例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));
}
示例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));
}
示例6: __construct
public function __construct()
{
parent::__construct('SetLabelDescriptionAliases', 'edit');
$wikibaseRepo = WikibaseRepo::getDefaultInstance();
$this->changeOpFactory = $wikibaseRepo->getChangeOpFactoryProvider()->getFingerprintChangeOpFactory();
$this->termsLanguages = $wikibaseRepo->getTermsLanguages();
}
示例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;
}
示例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;
}
示例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;
}
示例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())));
}
示例11: setUp
protected function setUp()
{
parent::setUp();
$sitesTable = WikibaseRepo::getDefaultInstance()->getSiteStore();
$sitesTable->clear();
$sitesTable->saveSites(TestSites::getSites());
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}