private function findPropertyDescriptionBy(DIProperty $property) { if ($this->languageCode !== '') { $this->propertySpecificationLookup->setLanguageCode($this->languageCode); } $description = $this->propertySpecificationLookup->getPropertyDescriptionBy($property); if ($description === '' || $description === null) { return $description; } return array($this->propertySpecificationLookup->getLanguageCode() => $description); }
private function registerCallbackHandlersByConstructedInstance($callbackLoader) { /** * @var BlobStore */ $callbackLoader->registerCallback('BlobStore', function ($namespace, $cacheType = null, $ttl = 0) use($callbackLoader) { $callbackLoader->registerExpectedReturnType('BlobStore', '\\Onoi\\BlobStore\\BlobStore'); $cacheFactory = $callbackLoader->load('CacheFactory'); $blobStore = new BlobStore($namespace, $cacheFactory->newMediaWikiCompositeCache($cacheType)); $blobStore->setNamespacePrefix($cacheFactory->getCachePrefix()); $blobStore->setExpiryInSeconds($ttl); $blobStore->setUsageState($cacheType !== CACHE_NONE && $cacheType !== false); return $blobStore; }); /** * @var CachedQueryResultPrefetcher */ $callbackLoader->registerCallback('CachedQueryResultPrefetcher', function ($cacheType = null) use($callbackLoader) { $callbackLoader->registerExpectedReturnType('CachedQueryResultPrefetcher', '\\SMW\\CachedQueryResultPrefetcher'); $settings = $callbackLoader->load('Settings'); $cacheType = $cacheType === null ? $settings->get('smwgQueryResultCacheType') : $cacheType; $cachedQueryResultPrefetcher = new CachedQueryResultPrefetcher($callbackLoader->load('Store'), $callbackLoader->singleton('QueryFactory'), $callbackLoader->create('BlobStore', CachedQueryResultPrefetcher::CACHE_NAMESPACE, $cacheType, $settings->get('smwgQueryResultCacheLifetime')), $callbackLoader->singleton('TransientStatsdCollector', CachedQueryResultPrefetcher::STATSD_ID)); $cachedQueryResultPrefetcher->setLogger($callbackLoader->singleton('MediaWikiLogger')); $cachedQueryResultPrefetcher->setNonEmbeddedCacheLifetime($settings->get('smwgQueryResultNonEmbeddedCacheLifetime')); return $cachedQueryResultPrefetcher; }); /** * @var CachedPropertyValuesPrefetcher */ $callbackLoader->registerCallback('CachedPropertyValuesPrefetcher', function ($cacheType = null, $ttl = 604800) use($callbackLoader) { $callbackLoader->registerExpectedReturnType('CachedPropertyValuesPrefetcher', '\\SMW\\CachedPropertyValuesPrefetcher'); $cachedPropertyValuesPrefetcher = new CachedPropertyValuesPrefetcher($callbackLoader->load('Store'), $callbackLoader->load('BlobStore', CachedPropertyValuesPrefetcher::CACHE_NAMESPACE, $cacheType, $ttl)); return $cachedPropertyValuesPrefetcher; }); /** * @var TransientStatsdCollector */ $callbackLoader->registerCallback('TransientStatsdCollector', function ($id) use($callbackLoader) { $callbackLoader->registerExpectedReturnType('TransientStatsdCollector', '\\SMW\\TransientStatsdCollector'); // Explicitly use the DB to access a SqlBagOstuff instance $cacheType = CACHE_DB; $ttl = 0; $transientStatsdCollector = new TransientStatsdCollector($callbackLoader->create('BlobStore', TransientStatsdCollector::CACHE_NAMESPACE, $cacheType, $ttl), $id); return $transientStatsdCollector; }); /** * @var PropertySpecificationLookup */ $callbackLoader->registerCallback('PropertySpecificationLookup', function () use($callbackLoader) { $callbackLoader->registerExpectedReturnType('PropertySpecificationLookup', '\\SMW\\PropertySpecificationLookup'); $propertySpecificationLookup = new PropertySpecificationLookup($callbackLoader->singleton('CachedPropertyValuesPrefetcher'), $callbackLoader->singleton('InMemoryPoolCache')->getPoolCacheById(PropertySpecificationLookup::POOLCACHE_ID)); // Uses the language object selected in user preferences. It is one // of two global language objects $propertySpecificationLookup->setLanguageCode(Localizer::getInstance()->getUserLanguage()->getCode()); return $propertySpecificationLookup; }); /** * @var PropertyHierarchyLookup */ $callbackLoader->registerCallback('PropertyHierarchyLookup', function () use($callbackLoader) { $callbackLoader->registerExpectedReturnType('PropertyHierarchyLookup', '\\SMW\\PropertyHierarchyLookup'); $propertyHierarchyLookup = new PropertyHierarchyLookup($callbackLoader->load('Store'), $callbackLoader->singleton('InMemoryPoolCache')->getPoolCacheById(PropertyHierarchyLookup::POOLCACHE_ID)); $propertyHierarchyLookup->setSubcategoryDepth($callbackLoader->load('Settings')->get('smwgQSubcategoryDepth')); $propertyHierarchyLookup->setSubpropertyDepth($callbackLoader->load('Settings')->get('smwgQSubpropertyDepth')); return $propertyHierarchyLookup; }); /** * @var PropertyLabelFinder */ $callbackLoader->registerCallback('PropertyLabelFinder', function () use($callbackLoader) { $callbackLoader->registerExpectedReturnType('PropertyLabelFinder', '\\SMW\\PropertyLabelFinder'); $extraneousLanguage = Localizer::getInstance()->getExtraneousLanguage(); $propertyLabelFinder = new PropertyLabelFinder($callbackLoader->load('Store'), $extraneousLanguage->getPropertyLabels(), $extraneousLanguage->getCanonicalPropertyLabels()); return $propertyLabelFinder; }); /** * @var TransitionalDiffStore */ $callbackLoader->registerCallback('TransitionalDiffStore', function () use($callbackLoader) { $callbackLoader->registerExpectedReturnType('TransitionalDiffStore', '\\SMW\\SQLStore\\TransitionalDiffStore'); $cacheFactory = $callbackLoader->load('CacheFactory'); $cacheType = null; $transitionalDiffStore = new TransitionalDiffStore($cacheFactory->newMediaWikiCompositeCache($cacheType), $cacheFactory->getCachePrefix()); $transitionalDiffStore->setLogger($callbackLoader->singleton('MediaWikiLogger')); return $transitionalDiffStore; }); }
public function testTryToGetLocalPropertyDescriptionForUserdefinedProperty() { $property = $this->dataItemFactory->newDIProperty('Foo'); $pdesc = $this->dataItemFactory->newDIProperty('_PDESC'); $pdesc->setPropertyTypeId('_mlt_rec'); $container = $this->getMockBuilder('\\Onoi\\BlobStore\\Container')->disableOriginalConstructor()->getMock(); $this->blobStore->expects($this->once())->method('read')->will($this->returnValue($container)); $this->cachedPropertyValuesPrefetcher->expects($this->once())->method('getPropertyValues')->with($this->equalTo($property->getDiWikiPage()), $this->anything(), $this->anything())->will($this->returnValue(array($this->dataItemFactory->newDIContainer(ContainerSemanticData::makeAnonymousContainer())))); $this->cachedPropertyValuesPrefetcher->expects($this->once())->method('getBlobStore')->will($this->returnValue($this->blobStore)); $instance = new PropertySpecificationLookup($this->cachedPropertyValuesPrefetcher, $this->intermediaryMemoryCache); $this->assertInternalType('string', $instance->getPropertyDescriptionBy($property)); }