1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WikibaseQuality\ConstraintReport; |
4
|
|
|
|
5
|
|
|
use MediaWiki\MediaWikiServices; |
6
|
|
|
use Wikibase\DataModel\Services\Lookup\EntityLookup; |
7
|
|
|
use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* These services should really be registered by Wikibase, |
11
|
|
|
* but Wikibase doesn’t register them yet |
12
|
|
|
* and we need them to be registered as services for some tests, |
13
|
|
|
* so for now we register them on Wikibase’ behalf. |
14
|
|
|
* |
15
|
|
|
* @license GPL-2.0-or-later |
16
|
|
|
*/ |
17
|
|
|
class WikibaseServices { |
18
|
|
|
|
19
|
|
|
const ENTITY_LOOKUP = 'WBQC_EntityLookup'; |
20
|
|
|
const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21
|
|
|
const ENTITY_LOOKUP_WIHTOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
22
|
|
|
|
23
|
|
|
private static function getService( MediaWikiServices $services = null, $name ) { |
24
|
|
|
if ( $services === null ) { |
25
|
|
|
$services = MediaWikiServices::getInstance(); |
26
|
|
|
} |
27
|
|
|
return $services->getService( $name ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param MediaWikiServices|null $services |
32
|
|
|
* @return EntityLookup |
33
|
|
|
*/ |
34
|
|
|
public static function getEntityLookup( MediaWikiServices $services = null ) { |
35
|
|
|
return self::getService( $services, self::ENTITY_LOOKUP ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param MediaWikiServices|null $services |
40
|
|
|
* @return PropertyDataTypeLookup |
41
|
|
|
*/ |
42
|
|
|
public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) { |
43
|
|
|
return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param MediaWikiServices|null $services |
48
|
|
|
* @return EntityLookup |
49
|
|
|
*/ |
50
|
|
|
public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) { |
51
|
|
|
return self::getService( $services, self::ENTITY_LOOKUP_WIHTOUT_CACHE ); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|