Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
63.64% |
7 / 11 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
CognateInstallerTask | |
63.64% |
7 / 11 |
|
25.00% |
1 / 4 |
7.73 | |
0.00% |
0 / 1 |
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDependencies | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
75.00% |
6 / 8 |
|
0.00% |
0 / 1 |
3.14 |
1 | <?php |
2 | |
3 | namespace Cognate; |
4 | |
5 | use MediaWiki\Installer\Task\Task; |
6 | use MediaWiki\Language\RawMessage; |
7 | use MediaWiki\MainConfigNames; |
8 | use MediaWiki\Status\Status; |
9 | use MediaWiki\WikiMap\WikiMap; |
10 | |
11 | class CognateInstallerTask extends Task { |
12 | /** |
13 | * @return string |
14 | */ |
15 | public function getName() { |
16 | return 'cognate-sites'; |
17 | } |
18 | |
19 | /** |
20 | * @return string |
21 | */ |
22 | public function getDescription() { |
23 | return 'Adding Cognate site'; |
24 | } |
25 | |
26 | /** |
27 | * @return string[] |
28 | */ |
29 | public function getDependencies() { |
30 | return [ 'services', 'extension-tables' ]; |
31 | } |
32 | |
33 | public function execute(): Status { |
34 | $status = Status::newGood(); |
35 | $interwikis = $this->getConfigVar( MainConfigNames::LocalInterwikis ); |
36 | if ( !is_array( $interwikis ) || !isset( $interwikis[0] ) ) { |
37 | $status->warning( new RawMessage( 'Can\'t add Cognate site: no local interwiki prefix' ) ); |
38 | return $status; |
39 | } |
40 | |
41 | CognateServices::getStore( $this->getServices() ) |
42 | ->insertSites( [ WikiMap::getCurrentWikiId() => $interwikis[0] ] ); |
43 | return $status; |
44 | } |
45 | } |