Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
37 / 37 |
|
100.00% |
10 / 10 |
CRAP | |
100.00% |
1 / 1 |
HookRunner | |
100.00% |
37 / 37 |
|
100.00% |
10 / 10 |
10 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
onBeforePageDisplayMobile | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onEnterMobileMode | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onGetMobileUrl | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onMobileFrontendBeforeDOM | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onMobileFrontendContentProvider | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onMobileFrontendFeaturesRegistration | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onMobileSpecialPageStyles | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onRequestContextCreateSkinMobile | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
onSpecialMobileEditWatchlist__images | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
4 | |
5 | namespace MobileFrontend\Hooks; |
6 | |
7 | use IContextSource; |
8 | use MediaWiki\HookContainer\HookContainer; |
9 | use MediaWiki\Output\OutputPage; |
10 | use MobileContext; |
11 | use MobileFormatter; |
12 | use MobileFrontend\ContentProviders\IContentProvider; |
13 | use MobileFrontend\Features\FeaturesManager; |
14 | use Skin; |
15 | |
16 | /** |
17 | * This is a hook runner class, see docs/Hooks.md in core. |
18 | * @internal |
19 | */ |
20 | class HookRunner implements |
21 | BeforePageDisplayMobileHook, |
22 | EnterMobileModeHook, |
23 | GetMobileUrlHook, |
24 | MobileFrontendBeforeDOMHook, |
25 | MobileFrontendContentProviderHook, |
26 | MobileFrontendFeaturesRegistrationHook, |
27 | MobileSpecialPageStylesHook, |
28 | RequestContextCreateSkinMobileHook, |
29 | SpecialMobileEditWatchlistImagesHook |
30 | { |
31 | private HookContainer $hookContainer; |
32 | |
33 | public function __construct( HookContainer $hookContainer ) { |
34 | $this->hookContainer = $hookContainer; |
35 | } |
36 | |
37 | /** |
38 | * @inheritDoc |
39 | */ |
40 | public function onBeforePageDisplayMobile( OutputPage &$out, Skin &$skin ) { |
41 | return $this->hookContainer->run( |
42 | 'BeforePageDisplayMobile', |
43 | [ &$out, &$skin ] |
44 | ); |
45 | } |
46 | |
47 | /** |
48 | * @inheritDoc |
49 | */ |
50 | public function onEnterMobileMode( MobileContext $mobileContext ) { |
51 | return $this->hookContainer->run( |
52 | 'EnterMobileMode', |
53 | [ $mobileContext ] |
54 | ); |
55 | } |
56 | |
57 | /** |
58 | * @inheritDoc |
59 | */ |
60 | public function onGetMobileUrl( ?string &$subdomainTokenReplacement, MobileContext $context ) { |
61 | return $this->hookContainer->run( |
62 | 'GetMobileUrl', |
63 | [ &$subdomainTokenReplacement, $context ] |
64 | ); |
65 | } |
66 | |
67 | /** |
68 | * @inheritDoc |
69 | */ |
70 | public function onMobileFrontendBeforeDOM( MobileContext $mobileContext, MobileFormatter $formatter ) { |
71 | return $this->hookContainer->run( |
72 | 'MobileFrontendBeforeDOM', |
73 | [ $mobileContext, $formatter ] |
74 | ); |
75 | } |
76 | |
77 | /** |
78 | * @inheritDoc |
79 | */ |
80 | public function onMobileFrontendContentProvider( IContentProvider &$provider, OutputPage $out ) { |
81 | return $this->hookContainer->run( |
82 | 'MobileFrontendContentProvider', |
83 | [ &$provider, $out ] |
84 | ); |
85 | } |
86 | |
87 | /** |
88 | * @inheritDoc |
89 | */ |
90 | public function onMobileFrontendFeaturesRegistration( FeaturesManager $featuresManager ) { |
91 | return $this->hookContainer->run( |
92 | 'MobileFrontendFeaturesRegistration', |
93 | [ $featuresManager ] |
94 | ); |
95 | } |
96 | |
97 | /** |
98 | * @inheritDoc |
99 | */ |
100 | public function onMobileSpecialPageStyles( string $id, OutputPage $out ) { |
101 | return $this->hookContainer->run( |
102 | 'MobileSpecialPageStyles', |
103 | [ $id, $out ] |
104 | ); |
105 | } |
106 | |
107 | /** |
108 | * @inheritDoc |
109 | */ |
110 | public function onRequestContextCreateSkinMobile( MobileContext $mobileContext, Skin $skin ) { |
111 | return $this->hookContainer->run( |
112 | 'RequestContextCreateSkinMobile', |
113 | [ $mobileContext, $skin ] |
114 | ); |
115 | } |
116 | |
117 | /** |
118 | * @inheritDoc |
119 | */ |
120 | public function onSpecialMobileEditWatchlist__images( IContextSource $context, array &$watchlist, array &$images ) { |
121 | return $this->hookContainer->run( |
122 | 'SpecialMobileEditWatchlist::images', |
123 | [ $context, &$watchlist, &$images ] |
124 | ); |
125 | } |
126 | } |