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