1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WikibaseQuality\ConstraintReport; |
4
|
|
|
|
5
|
|
|
use MediaWiki\MediaWikiServices; |
6
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; |
7
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; |
8
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\LoggingHelper; |
9
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; |
10
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper; |
11
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; |
12
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageDeserializer; |
13
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageSerializer; |
14
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultDeserializer; |
15
|
|
|
use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @license GPL-2.0-or-later |
19
|
|
|
*/ |
20
|
|
|
class ConstraintsServices { |
21
|
|
|
|
22
|
|
|
const LOGGING_HELPER = 'WBQC_LoggingHelper'; |
23
|
|
|
const CONSTRAINT_REPOSITORY = 'WBQC_ConstraintRepository'; |
24
|
|
|
const CONSTRAINT_LOOKUP = 'WBQC_ConstraintLookup'; |
25
|
|
|
const CHECK_RESULT_SERIALIZER = 'WBQC_CheckResultSerializer'; |
26
|
|
|
const CHECK_RESULT_DESERIALIZER = 'WBQC_CheckResultDeserializer'; |
27
|
|
|
const VIOLATION_MESSAGE_SERIALIZER = 'WBQC_ViolationMessageSerializer'; |
28
|
|
|
const VIOLATION_MESSAGE_DESERIALIZER = 'WBQC_ViolationMessageDeserializer'; |
29
|
|
|
const CONSTRAINT_PARAMETER_PARSER = 'WBQC_ConstraintParameterParser'; |
30
|
|
|
const CONNECTION_CHECKER_HELPER = 'WBQC_ConnectionCheckerHelper'; |
31
|
|
|
const RANGE_CHECKER_HELPER = 'WBQC_RangeCheckerHelper'; |
32
|
|
|
const SPARQL_HELPER = 'WBQC_SparqlHelper'; |
33
|
|
|
const TYPE_CHECKER_HELPER = 'WBQC_TypeCheckerHelper'; |
34
|
|
|
|
35
|
|
|
private static function getService( MediaWikiServices $services = null, $name ) { |
36
|
|
|
if ( $services === null ) { |
37
|
|
|
$services = MediaWikiServices::getInstance(); |
38
|
|
|
} |
39
|
|
|
return $services->getService( $name ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param MediaWikiServices|null $services |
44
|
|
|
* @return LoggingHelper |
45
|
|
|
*/ |
46
|
|
|
public static function getLoggingHelper( MediaWikiServices $services = null ) { |
47
|
|
|
return self::getService( $services, self::LOGGING_HELPER ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param MediaWikiServices|null $services |
52
|
|
|
* @return ConstraintRepository |
53
|
|
|
*/ |
54
|
|
|
public static function getConstraintRepository( MediaWikiServices $services = null ) { |
55
|
|
|
return self::getService( $services, self::CONSTRAINT_REPOSITORY ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param MediaWikiServices|null $services |
60
|
|
|
* @return ConstraintLookup |
61
|
|
|
*/ |
62
|
|
|
public static function getConstraintLookup( MediaWikiServices $services = null ) { |
63
|
|
|
return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param MediaWikiServices|null $services |
68
|
|
|
* @return CheckResultSerializer |
69
|
|
|
*/ |
70
|
|
|
public static function getCheckResultSerializer( MediaWikiServices $services = null ) { |
71
|
|
|
return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param MediaWikiServices|null $services |
76
|
|
|
* @return CheckResultDeserializer |
77
|
|
|
*/ |
78
|
|
|
public static function getCheckResultDeserializer( MediaWikiServices $services = null ) { |
79
|
|
|
return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param MediaWikiServices|null $services |
84
|
|
|
* @return ViolationMessageSerializer |
85
|
|
|
*/ |
86
|
|
|
public static function getViolationMessageSerializer( MediaWikiServices $services = null ) { |
87
|
|
|
return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param MediaWikiServices|null $services |
92
|
|
|
* @return ViolationMessageDeserializer |
93
|
|
|
*/ |
94
|
|
|
public static function getViolationMessageDeserializer( MediaWikiServices $services = null ) { |
95
|
|
|
return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param MediaWikiServices|null $services |
100
|
|
|
* @return ConstraintParameterParser |
101
|
|
|
*/ |
102
|
|
|
public static function getConstraintParameterParser( MediaWikiServices $services = null ) { |
103
|
|
|
return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param MediaWikiServices|null $services |
108
|
|
|
* @return ConnectionCheckerHelper |
109
|
|
|
*/ |
110
|
|
|
public static function getConnectionCheckerHelper( MediaWikiServices $services = null ) { |
111
|
|
|
return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param MediaWikiServices|null $services |
116
|
|
|
* @return RangeCheckerHelper |
117
|
|
|
*/ |
118
|
|
|
public static function getRangeCheckerHelper( MediaWikiServices $services = null ) { |
119
|
|
|
return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param MediaWikiServices|null $services |
124
|
|
|
* @return SparqlHelper |
125
|
|
|
*/ |
126
|
|
|
public static function getSparqlHelper( MediaWikiServices $services = null ) { |
127
|
|
|
return self::getService( $services, self::SPARQL_HELPER ); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param MediaWikiServices|null $services |
132
|
|
|
* @return TypeCheckerHelper |
133
|
|
|
*/ |
134
|
|
|
public static function getTypeCheckerHelper( MediaWikiServices $services = null ) { |
135
|
|
|
return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
} |
139
|
|
|
|