/** * 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; }
/** * @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'); }
/** * 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); }
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)); }
/** * @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)); }
public function __construct() { parent::__construct('SetLabelDescriptionAliases', 'edit'); $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $this->changeOpFactory = $wikibaseRepo->getChangeOpFactoryProvider()->getFingerprintChangeOpFactory(); $this->termsLanguages = $wikibaseRepo->getTermsLanguages(); }
/** * @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; }
/** * @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; }
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; }
/** * @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()))); }
protected function setUp() { parent::setUp(); $sitesTable = WikibaseRepo::getDefaultInstance()->getSiteStore(); $sitesTable->clear(); $sitesTable->saveSites(TestSites::getSites()); }
/** * @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); }
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; }
/** * @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); }
/** * @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); }
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); }
/** * @see ApiBase::execute * * @since 0.5 */ public function execute() { $badgeItems = WikibaseRepo::getDefaultInstance()->getSettings()->getSetting('badgeItems'); $idStrings = array_keys($badgeItems); ApiResult::setIndexedTagName($idStrings, 'badge'); $this->getResult()->addValue(null, 'badges', $idStrings); }
/** * Creates a EntityDataRequestHandler based on global defaults. * * @return EntityDataRequestHandler */ private function newDefaultRequestHandler() { global $wgUseSquid, $wgApiFrameOptions; $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $entityRevisionLookup = $wikibaseRepo->getEntityRevisionLookup(); $entityRedirectLookup = $wikibaseRepo->getStore()->getEntityRedirectLookup(); $titleLookup = $wikibaseRepo->getEntityTitleLookup(); $entityIdParser = $wikibaseRepo->getEntityIdParser(); $entityDataFormatProvider = new EntityDataFormatProvider(); $serializerFactory = new SerializerFactory(new DataValueSerializer(), SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH + SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH); $languageCodes = array_merge($GLOBALS['wgDummyLanguageCodes'], $wikibaseRepo->getSettings()->getSetting('canonicalLanguageCodes')); $serializationService = new EntityDataSerializationService($wikibaseRepo->getSettings()->getSetting('conceptBaseUri'), $this->getPageTitle()->getCanonicalURL() . '/', $wikibaseRepo->getStore()->getEntityLookup(), $titleLookup, $wikibaseRepo->getPropertyDataTypeLookup(), $wikibaseRepo->getValueSnakRdfBuilderFactory(), $wikibaseRepo->getSiteStore()->getSites(), $entityDataFormatProvider, $serializerFactory, $wikibaseRepo->getSiteStore(), $languageCodes); $maxAge = $wikibaseRepo->getSettings()->getSetting('dataSquidMaxage'); $formats = $wikibaseRepo->getSettings()->getSetting('entityDataFormats'); $entityDataFormatProvider->setFormatWhiteList($formats); $defaultFormat = empty($formats) ? 'html' : $formats[0]; // build a mapping of formats to file extensions and include HTML $supportedExtensions = array(); $supportedExtensions['html'] = 'html'; foreach ($entityDataFormatProvider->getSupportedFormats() as $format) { $ext = $entityDataFormatProvider->getExtension($format); if ($ext !== null) { $supportedExtensions[$format] = $ext; } } $uriManager = new EntityDataUriManager($this->getPageTitle(), $supportedExtensions, $titleLookup); return new EntityDataRequestHandler($uriManager, $titleLookup, $entityIdParser, $entityRevisionLookup, $entityRedirectLookup, $serializationService, $entityDataFormatProvider, $defaultFormat, $maxAge, $wgUseSquid, $wgApiFrameOptions); }
/** * @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()); } }
/** * @param EntityDocument $entity */ private function save(EntityDocument $entity) { $flags = $entity->getId() ? EDIT_UPDATE : EDIT_NEW; $store = WikibaseRepo::getDefaultInstance()->getEntityStore(); $rev = $store->saveEntity($entity, '', $GLOBALS['wgUser'], $flags); $entity->setId($rev->getEntity()->getId()); }
private function newRequestHandler() { $mockRepository = EntityDataTestProvider::getMockRepository(); $titleLookup = $this->getMock('Wikibase\\Lib\\Store\\EntityTitleLookup'); $titleLookup->expects($this->any())->method('getTitleForId')->will($this->returnCallback(function (EntityId $id) { return Title::newFromText($id->getEntityType() . ':' . $id->getSerialization()); })); $dataTypeLookup = $this->getMock('Wikibase\\DataModel\\Services\\Lookup\\PropertyDataTypeLookup'); $dataTypeLookup->expects($this->any())->method('getDataTypeIdForProperty')->will($this->returnValue('string')); $entityDataFormatProvider = new EntityDataFormatProvider(); $serializerFactory = new SerializerFactory(new DataValueSerializer(), SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH + SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH); // Note: We are testing with the actual RDF bindings. These should not change for well // known data types. Mocking the bindings would be nice, but is complex and not needed. $rdfBuilder = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory(); $serializationService = new EntityDataSerializationService(self::URI_BASE, self::URI_DATA, $mockRepository, $titleLookup, $dataTypeLookup, $rdfBuilder, new SiteList(), $entityDataFormatProvider, $serializerFactory, new HashSiteStore()); $formats = array('json', 'rdfxml', 'ntriples'); $entityDataFormatProvider->setFormatWhiteList($formats); $defaultFormat = 'rdf'; $supportedExtensions = array_combine($formats, $formats); $title = SpecialPage::getTitleFor('EntityData'); $uriManager = new EntityDataUriManager($title, $supportedExtensions, $titleLookup); $useSquid = false; $apiFrameOptions = 'DENY'; return new EntityDataRequestHandler($uriManager, $titleLookup, new BasicEntityIdParser(), $mockRepository, $mockRepository, $serializationService, $entityDataFormatProvider, $defaultFormat, 0, $useSquid, $apiFrameOptions); }
private function getEntityContentDataCodec() { if (!isset($this->codec)) { $this->codec = WikibaseRepo::getDefaultInstance()->getEntityContentDataCodec(); } return $this->codec; }
/** * @param ApiQuery $apiQuery * @param string $moduleName * @param string $modulePrefix * * @see ApiBase::__construct */ public function __construct(ApiQuery $apiQuery, $moduleName, $modulePrefix = 'wbs') { parent::__construct($apiQuery, $moduleName, $modulePrefix); $repo = WikibaseRepo::getDefaultInstance(); $entitySearchHelper = new EntitySearchHelper($repo->getEntityTitleLookup(), $repo->getEntityIdParser(), $repo->newTermSearchInteractor($this->getLanguage()->getCode()), new LanguageFallbackLabelDescriptionLookup($repo->getTermLookup(), $repo->getLanguageFallbackChainFactory()->newFromLanguage($this->getLanguage()))); $this->setServices($entitySearchHelper, $repo->getEntityTitleLookup(), $repo->getTermsLanguages(), $repo->getEntityFactory()->getEntityTypes()); }
/** * @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), $wikibaseRepo->newItemMergeInteractor($this->getContext())); }
private function getNewInstance() { $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $api = new ApiMain(); $errorReporter = new ApiErrorReporter($api, new DispatchingExceptionLocalizer(array()), $api->getLanguage()); return new StatementModificationHelper($wikibaseRepo->getSnakConstructionService(), $wikibaseRepo->getEntityIdParser(), $wikibaseRepo->getStatementGuidValidator(), $errorReporter); }
/** * @param int $flavor Bitmap for the output flavor, use RdfProducer::PRODUCE_XXX constants. * @param EntityId[] &$mentioned Receives any entity IDs being mentioned. * @param DedupeBag $dedupe A bag of reference hashes that should be considered "already seen". * * @return FullStatementRdfBuilder */ private function newBuilder($flavor, array &$mentioned = array(), DedupeBag $dedupe = null) { $vocabulary = $this->getTestData()->getVocabulary(); $writer = $this->getTestData()->getNTriplesWriter(); $mentionTracker = $this->getMock('Wikibase\\Rdf\\EntityMentionListener'); $mentionTracker->expects($this->any())->method('propertyMentioned')->will($this->returnCallback(function (EntityId $id) use(&$mentioned) { $key = $id->getSerialization(); $mentioned[$key] = $id; })); // Note: using the actual factory here makes this an integration test! $valueBuilderFactory = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory(); if ($flavor & RdfProducer::PRODUCE_FULL_VALUES) { $valueWriter = $writer->sub(); $statementValueBuilder = $valueBuilderFactory->getComplexValueSnakRdfBuilder($this->getTestData()->getVocabulary(), $valueWriter, $mentionTracker, new HashDedupeBag()); } else { $statementValueBuilder = $valueBuilderFactory->getSimpleValueSnakRdfBuilder($this->getTestData()->getVocabulary(), $writer, $mentionTracker, new HashDedupeBag()); } $snakRdfBuilder = new SnakRdfBuilder($vocabulary, $statementValueBuilder, $this->getTestData()->getMockRepository()); $statementBuilder = new FullStatementRdfBuilder($vocabulary, $writer, $snakRdfBuilder); $statementBuilder->setDedupeBag($dedupe ?: new NullDedupeBag()); if ($flavor & RdfProducer::PRODUCE_PROPERTIES) { $snakRdfBuilder->setEntityMentionListener($mentionTracker); } $statementBuilder->setProduceQualifiers($flavor & RdfProducer::PRODUCE_QUALIFIERS); $statementBuilder->setProduceReferences($flavor & RdfProducer::PRODUCE_REFERENCES); // HACK: stick the writer into a public field, for use by getDataFromBuilder() $statementBuilder->test_writer = $writer; return $statementBuilder; }
/** * @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); $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $changeOpFactoryProvider = $wikibaseRepo->getChangeOpFactoryProvider(); $this->termChangeOpFactory = $changeOpFactoryProvider->getFingerprintChangeOpFactory(); $this->termsLanguages = $wikibaseRepo->getTermsLanguages(); }
/** * @see SpecialWikibasePage::__construct * * @since 0.1 */ public function __construct() { // args $name, $restriction, $listed parent::__construct('ItemByTitle', '', true); $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $this->initSettings($wikibaseRepo->getSettings()->getSetting('siteLinkGroups')); $this->initServices($wikibaseRepo->getEntityTitleLookup(), $wikibaseRepo->getSiteStore(), $wikibaseRepo->getStore()->newSiteLinkStore()); }
private function createEntityRedirect(EntityId $target) { $id = $this->createEntity('Dummy'); $redirect = new EntityRedirect($id, $target); $store = WikibaseRepo::getDefaultInstance()->getEntityStore(); $store->saveRedirect($redirect, 'GetEntitiesRedirectTest', $GLOBALS['wgUser'], EDIT_UPDATE); return $id; }
/** * @return EntityContentDataCodec */ private function getCodec() { if ($this->codec === null) { $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $this->codec = $wikibaseRepo->getEntityContentDataCodec(); } return $this->codec; }