Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ULSRelevantLanguagesEntrypointRegistrationHandler | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
onBeforePageDisplay | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace ContentTranslation\HookHandler; |
6 | |
7 | use ContentTranslation\PreferenceHelper; |
8 | use MediaWiki\Hook\BeforePageDisplayHook; |
9 | |
10 | class ULSRelevantLanguagesEntrypointRegistrationHandler implements BeforePageDisplayHook { |
11 | |
12 | /** @var PreferenceHelper */ |
13 | private $preferenceHelper; |
14 | |
15 | public function __construct( PreferenceHelper $preferenceHelper ) { |
16 | $this->preferenceHelper = $preferenceHelper; |
17 | } |
18 | |
19 | public function onBeforePageDisplay( $out, $skin ): void { |
20 | $user = $out->getUser(); |
21 | // Enable entrypoint only on Wikipedias where Content Translation is enabled and only for users |
22 | // that have not disabled CX entrypoints |
23 | if ( |
24 | !$this->preferenceHelper->isEnabledForUser( $user ) |
25 | || $this->preferenceHelper->isCXEntrypointDisabled( $user ) |
26 | ) { |
27 | return; |
28 | } |
29 | |
30 | $isContentPage = $out->getTitle()->isContentPage(); |
31 | |
32 | if ( !$isContentPage ) { |
33 | return; |
34 | } |
35 | |
36 | $out->addModules( 'ext.cx.entrypoints.ulsrelevantlanguages' ); |
37 | } |
38 | } |