1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WikibaseQuality\ConstraintReport; |
4
|
|
|
|
5
|
|
|
use MediaWiki\MediaWikiServices; |
6
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; |
7
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\LoggingHelper; |
8
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageDeserializer; |
9
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageSerializer; |
10
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultDeserializer; |
11
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @license GPL-2.0-or-later |
15
|
|
|
*/ |
16
|
|
|
class ConstraintsServices { |
17
|
|
|
|
18
|
|
|
const LOGGING_HELPER = 'WBQC_LoggingHelper'; |
19
|
|
|
const CONSTRAINT_REPOSITORY = 'WBQC_ConstraintRepository'; |
20
|
|
|
const CONSTRAINT_LOOKUP = 'WBQC_ConstraintLookup'; |
21
|
|
|
const CHECK_RESULT_SERIALIZER = 'WBQC_CheckResultSerializer'; |
22
|
|
|
const CHECK_RESULT_DESERIALIZER = 'WBQC_CheckResultDeserializer'; |
23
|
|
|
const VIOLATION_MESSAGE_SERIALIZER = 'WBQC_ViolationMessageSerializer'; |
24
|
|
|
const VIOLATION_MESSAGE_DESERIALIZER = 'WBQC_ViolationMessageDeserializer'; |
25
|
|
|
const CONSTRAINT_PARAMETER_PARSER = 'WBQC_ConstraintParameterParser'; |
26
|
|
|
|
27
|
|
|
private static function getService( MediaWikiServices $services = null, $name ) { |
28
|
|
|
if ( $services === null ) { |
29
|
|
|
$services = MediaWikiServices::getInstance(); |
30
|
|
|
} |
31
|
|
|
return $services->getService( $name ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param MediaWikiServices|null $services |
36
|
|
|
* @return LoggingHelper |
37
|
|
|
*/ |
38
|
|
|
public static function getLoggingHelper( MediaWikiServices $services = null ) { |
39
|
|
|
return self::getService( $services, self::LOGGING_HELPER ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param MediaWikiServices|null $services |
44
|
|
|
* @return ConstraintRepository |
45
|
|
|
*/ |
46
|
|
|
public static function getConstraintRepository( MediaWikiServices $services = null ) { |
47
|
|
|
return self::getService( $services, self::CONSTRAINT_REPOSITORY ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param MediaWikiServices|null $services |
52
|
|
|
* @return ConstraintLookup |
53
|
|
|
*/ |
54
|
|
|
public static function getConstraintLookup( MediaWikiServices $services = null ) { |
55
|
|
|
return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param MediaWikiServices|null $services |
60
|
|
|
* @return CheckResultSerializer |
61
|
|
|
*/ |
62
|
|
|
public static function getCheckResultSerializer( MediaWikiServices $services = null ) { |
63
|
|
|
return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param MediaWikiServices|null $services |
68
|
|
|
* @return CheckResultDeserializer |
69
|
|
|
*/ |
70
|
|
|
public static function getCheckResultDeserializer( MediaWikiServices $services = null ) { |
71
|
|
|
return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param MediaWikiServices|null $services |
76
|
|
|
* @return ViolationMessageSerializer |
77
|
|
|
*/ |
78
|
|
|
public static function getViolationMessageSerializer( MediaWikiServices $services = null ) { |
79
|
|
|
return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param MediaWikiServices|null $services |
84
|
|
|
* @return ViolationMessageDeserializer |
85
|
|
|
*/ |
86
|
|
|
public static function getViolationMessageDeserializer( MediaWikiServices $services = null ) { |
87
|
|
|
return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param MediaWikiServices|null $services |
92
|
|
|
* @return ConstraintParameterParser |
93
|
|
|
*/ |
94
|
|
|
public static function getConstraintParameterParser( MediaWikiServices $services = null ) { |
95
|
|
|
return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
} |
99
|
|
|
|