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\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    public function onBeforePageDisplay( $out, $skin ): void {
20        $title = $out->getTitle();
21        $action = $this->actionFactory->getActionName( $out->getContext() );
22        $isVector2022Skin = $skin->getSkinName() === 'vector-2022';
23        $isView = $action === 'view';
24
25        // Do not load the module:
26        // 1. if page doesn't exist
27        // 2. if page is the Main Page
28        // 3. if action is other than "view"
29        // 4. if namespace is not a "Content" (article) namespace
30        // 5. if skin is other than Vector 2022
31        if ( !$title->exists() || $title->isMainPage() || !$isView || !$title->isContentPage() || !$isVector2022Skin ) {
32            return;
33        }
34
35        $out->addModules( 'ext.cx.uls.quick.actions' );
36    }
37}