Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ULSQuickActionEntrypointRegistrationHandler | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| onBeforePageDisplay | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
42 | |||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace ContentTranslation\HookHandler; |
| 6 | |
| 7 | use MediaWiki\Actions\ActionFactory; |
| 8 | use MediaWiki\Output\Hook\BeforePageDisplayHook; |
| 9 | |
| 10 | class ULSQuickActionEntrypointRegistrationHandler implements BeforePageDisplayHook { |
| 11 | |
| 12 | public function __construct( private readonly ActionFactory $actionFactory ) { |
| 13 | } |
| 14 | |
| 15 | /** @inheritDoc */ |
| 16 | public function onBeforePageDisplay( $out, $skin ): void { |
| 17 | $title = $out->getTitle(); |
| 18 | $action = $this->actionFactory->getActionName( $out->getContext() ); |
| 19 | $isVector2022Skin = $skin->getSkinName() === 'vector-2022'; |
| 20 | $isView = $action === 'view'; |
| 21 | |
| 22 | // Do not load the module: |
| 23 | // 1. if page doesn't exist |
| 24 | // 2. if page is the Main Page |
| 25 | // 3. if action is other than "view" |
| 26 | // 4. if namespace is not a "Content" (article) namespace |
| 27 | // 5. if skin is other than Vector 2022 |
| 28 | if ( !$title->exists() || $title->isMainPage() || !$isView || !$title->isContentPage() || !$isVector2022Skin ) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | $out->addModules( 'ext.cx.uls.quick.actions' ); |
| 33 | } |
| 34 | } |