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