Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
85.71% |
12 / 14 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
CategorySpamlistLookup | |
85.71% |
12 / 14 |
|
33.33% |
1 / 3 |
4.05 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
fetchTargets | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
2 | |||
isCachable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\MassMessage\Lookup; |
4 | |
5 | use MediaWiki\Category\Category; |
6 | use MediaWiki\MainConfigNames; |
7 | use MediaWiki\MassMessage\UrlHelper; |
8 | use MediaWiki\MediaWikiServices; |
9 | use MediaWiki\Title\Title; |
10 | use MediaWiki\WikiMap\WikiMap; |
11 | |
12 | class CategorySpamlistLookup extends SpamlistLookup { |
13 | |
14 | /** |
15 | * @var Title |
16 | */ |
17 | protected $spamlist; |
18 | |
19 | /** |
20 | * @param Title $spamlist |
21 | */ |
22 | public function __construct( Title $spamlist ) { |
23 | $this->spamlist = $spamlist; |
24 | } |
25 | |
26 | /** |
27 | * Get an array of targets from a category |
28 | * @return array[] |
29 | */ |
30 | public function fetchTargets() { |
31 | $members = Category::newFromTitle( $this->spamlist )->getMembers(); |
32 | $targets = []; |
33 | $currentWikiId = WikiMap::getCurrentWikiId(); |
34 | |
35 | /** @var Title $member */ |
36 | foreach ( $members as $member ) { |
37 | $targets[] = [ |
38 | 'title' => $member->getPrefixedText(), |
39 | 'wiki' => $currentWikiId, |
40 | 'site' => UrlHelper::getBaseUrl( |
41 | MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::CanonicalServer ) |
42 | ), |
43 | ]; |
44 | } |
45 | return $targets; |
46 | } |
47 | |
48 | /** |
49 | * @return false |
50 | */ |
51 | public function isCachable() { |
52 | return false; |
53 | } |
54 | } |