2
2
3
3
namespace Liquipedia \Extension \ResourceLoaderArticles \Hooks ;
4
4
5
- use ContentHandler ;
6
5
use Liquipedia \Extension \ResourceLoaderArticles \ResourceLoader \ResourceLoaderArticlesModule ;
6
+ use MediaWiki \Content \ContentHandlerFactory ;
7
7
use MediaWiki \Hook \BeforePageDisplayHook ;
8
8
use MediaWiki \Hook \MakeGlobalVariablesScriptHook ;
9
- use MediaWiki \MediaWikiServices ;
10
9
use MediaWiki \ResourceLoader \Hook \ResourceLoaderRegisterModulesHook ;
10
+ use MediaWiki \ResourceLoader \ResourceLoader ;
11
11
use MediaWiki \Revision \Hook \ContentHandlerDefaultModelForHook ;
12
12
use MediaWiki \Revision \RevisionLookup ;
13
13
use MediaWiki \Revision \SlotRecord ;
14
14
use OutputPage ;
15
- use ResourceLoader ;
16
15
use Skin ;
17
16
use Title ;
18
17
@@ -23,6 +22,17 @@ class MainHookHandler implements
23
22
ResourceLoaderRegisterModulesHook
24
23
{
25
24
25
+ private ContentHandlerFactory $ contentHandlerFactory ;
26
+ private RevisionLookup $ revisionLookup ;
27
+
28
+ public function __construct (
29
+ ContentHandlerFactory $ contentHandlerFactory ,
30
+ RevisionLookup $ revisionLookup
31
+ ) {
32
+ $ this ->contentHandlerFactory = $ contentHandlerFactory ;
33
+ $ this ->revisionLookup = $ revisionLookup ;
34
+ }
35
+
26
36
/**
27
37
* @param OutputPage $out
28
38
* @param Skin $skin
@@ -135,17 +145,15 @@ public function onResourceLoaderRegisterModules( ResourceLoader $rl ): void {
135
145
continue ;
136
146
}
137
147
138
- $ handler = ContentHandler:: getForTitle ( $ title );
148
+ $ handler = $ this -> contentHandlerFactory -> getContentHandler ( $ title-> getContentModel () );
139
149
if ( $ handler ->isSupportedFormat ( CONTENT_FORMAT_CSS ) ) {
140
150
$ format = CONTENT_FORMAT_CSS ;
141
151
} elseif ( $ handler ->isSupportedFormat ( CONTENT_FORMAT_JAVASCRIPT ) ) {
142
152
$ format = CONTENT_FORMAT_JAVASCRIPT ;
143
153
} else {
144
154
continue ;
145
155
}
146
- $ revision = MediaWikiServices::getInstance ()
147
- ->getRevisionLookup ()
148
- ->getRevisionByTitle ( $ title , 0 , RevisionLookup::READ_NORMAL );
156
+ $ revision = $ this ->revisionLookup ->getRevisionByTitle ( $ title , 0 , RevisionLookup::READ_NORMAL );
149
157
150
158
if ( !$ revision ) {
151
159
continue ;
0 commit comments