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