Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 13 |
LanguageLinksHandler | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 13 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
onLanguageLinks | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 5 |
<?php | |
namespace InterwikiSorting; | |
use Config; | |
use MediaWiki\Hook\LanguageLinksHook; | |
use Title; | |
/** | |
* @license GPL-2.0-or-later | |
*/ | |
class LanguageLinksHandler implements LanguageLinksHook { | |
/** | |
* @var InterwikiSorter | |
*/ | |
private $interwikiSorter; | |
/** | |
* @param Config $config | |
*/ | |
public function __construct( | |
Config $config | |
) { | |
$this->interwikiSorter = new InterwikiSorter( | |
$config->get( 'InterwikiSortingSort' ), | |
$config->get( 'InterwikiSortingInterwikiSortOrders' ), | |
$config->get( 'InterwikiSortingSortPrepend' ) | |
); | |
} | |
/** | |
* Sort Interwiki links according to predefined config settings | |
* @see https://www.mediawiki.org/wiki/Manual:Hooks/LanguageLinks | |
* | |
* @param Title $title | |
* @param string[] &$languageLinks | |
* @param array &$linkFlags | |
* @return void | |
*/ | |
public function onLanguageLinks( $title, &$languageLinks, &$linkFlags ): void { | |
// this hook tries to access repo SiteLinkTable | |
// it interferes with any test that parses something, like a page or a message | |
if ( defined( 'MW_PHPUNIT_TEST' ) ) { | |
return; | |
} | |
$languageLinks = $this->interwikiSorter->sortLinks( $languageLinks ); | |
} | |
} |