1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WikibaseQuality\ConstraintReport; |
4
|
|
|
|
5
|
|
|
use MediaWiki\MediaWikiServices; |
6
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\LoggingHelper; |
7
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultDeserializer; |
8
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @license GPL-2.0-or-later |
12
|
|
|
*/ |
13
|
|
|
class ConstraintsServices { |
14
|
|
|
|
15
|
|
|
const LOGGING_HELPER = 'WBQC_LoggingHelper'; |
16
|
|
|
const CONSTRAINT_REPOSITORY = 'WBQC_ConstraintRepository'; |
17
|
|
|
const CONSTRAINT_LOOKUP = 'WBQC_ConstraintLookup'; |
18
|
|
|
const CHECK_RESULT_SERIALIZER = 'WBQC_CheckResultSerializer'; |
19
|
|
|
const CHECK_RESULT_DESERIALIZER = 'WBQC_CheckResultDeserializer'; |
20
|
|
|
|
21
|
|
|
private static function getService( MediaWikiServices $services = null, $name ) { |
22
|
|
|
if ( $services === null ) { |
23
|
|
|
$services = MediaWikiServices::getInstance(); |
24
|
|
|
} |
25
|
|
|
return $services->getService( $name ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param MediaWikiServices|null $services |
30
|
|
|
* @return LoggingHelper |
31
|
|
|
*/ |
32
|
|
|
public static function getLoggingHelper( MediaWikiServices $services = null ) { |
33
|
|
|
return self::getService( $services, self::LOGGING_HELPER ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param MediaWikiServices|null $services |
38
|
|
|
* @return ConstraintRepository |
39
|
|
|
*/ |
40
|
|
|
public static function getConstraintRepository( MediaWikiServices $services = null ) { |
41
|
|
|
return self::getService( $services, self::CONSTRAINT_REPOSITORY ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param MediaWikiServices|null $services |
46
|
|
|
* @return ConstraintLookup |
47
|
|
|
*/ |
48
|
|
|
public static function getConstraintLookup( MediaWikiServices $services = null ) { |
49
|
|
|
return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param MediaWikiServices|null $services |
54
|
|
|
* @return CheckResultSerializer |
55
|
|
|
*/ |
56
|
|
|
public static function getCheckResultSerializer( MediaWikiServices $services = null ) { |
57
|
|
|
return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param MediaWikiServices|null $services |
62
|
|
|
* @return CheckResultDeserializer |
63
|
|
|
*/ |
64
|
|
|
public static function getCheckResultDeserializer( MediaWikiServices $services = null ) { |
65
|
|
|
return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|