1 | <?php |
||
20 | class HookRegistry { |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $handlers = array(); |
||
26 | |||
27 | /** |
||
28 | * @since 1.0 |
||
29 | * |
||
30 | * @param Store $store |
||
31 | * @param Cache $cache |
||
32 | * @param CacheKeyProvider $cacheKeyProvider |
||
33 | */ |
||
34 | 2 | public function __construct( Store $store, Cache $cache, CacheKeyProvider $cacheKeyProvider ) { |
|
35 | 2 | $this->addCallbackHandlers( $store, $cache, $cacheKeyProvider ); |
|
36 | 2 | } |
|
37 | |||
38 | /** |
||
39 | * @since 1.1 |
||
40 | * |
||
41 | * @param string $name |
||
42 | * |
||
43 | * @return boolean |
||
44 | */ |
||
45 | 1 | public function isRegistered( $name ) { |
|
48 | |||
49 | /** |
||
50 | * @since 1.1 |
||
51 | * |
||
52 | * @param string $name |
||
53 | * |
||
54 | * @return Callable|false |
||
55 | */ |
||
56 | 1 | public function getHandlerFor( $name ) { |
|
59 | |||
60 | /** |
||
61 | * @since 1.0 |
||
62 | */ |
||
63 | 1 | public function register() { |
|
68 | |||
69 | 9 | private function addCallbackHandlers( $store, $cache, $cacheKeyProvider ) { |
|
122 | |||
123 | 9 | private function registerInterlanguageParserHooks( InterlanguageLinksLookup $interlanguageLinksLookup ) { |
|
124 | |||
125 | 2 | $pageContentLanguageOnTheFlyModifier = new PageContentLanguageOnTheFlyModifier( |
|
126 | 2 | $interlanguageLinksLookup, |
|
127 | 2 | InMemoryPoolCache::getInstance()->getPoolCacheFor( PageContentLanguageOnTheFlyModifier::POOLCACHE_ID ) |
|
128 | 2 | ); |
|
129 | |||
130 | /** |
||
131 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit |
||
132 | */ |
||
133 | $this->handlers['ParserFirstCallInit'] = function ( &$parser ) use( $interlanguageLinksLookup, $pageContentLanguageOnTheFlyModifier ) { |
||
134 | |||
135 | 1 | $parserFunctionFactory = new ParserFunctionFactory(); |
|
136 | |||
137 | 1 | list( $name, $definition, $flag ) = $parserFunctionFactory->newInterlanguageLinkParserFunctionDefinition( |
|
138 | 1 | $interlanguageLinksLookup, |
|
139 | $pageContentLanguageOnTheFlyModifier |
||
140 | 1 | ); |
|
141 | |||
142 | 1 | $parser->setFunctionHook( $name, $definition, $flag ); |
|
143 | |||
144 | 1 | list( $name, $definition, $flag ) = $parserFunctionFactory->newInterlanguageListParserFunctionDefinition( |
|
145 | $interlanguageLinksLookup |
||
146 | 1 | ); |
|
147 | |||
148 | 1 | $parser->setFunctionHook( $name, $definition, $flag ); |
|
149 | |||
150 | 1 | return true; |
|
151 | }; |
||
152 | |||
153 | /** |
||
154 | * https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDelete |
||
155 | */ |
||
156 | $this->handlers['SMW::SQLStore::BeforeDeleteSubjectComplete'] = function ( $store, $title ) use ( $interlanguageLinksLookup ) { |
||
157 | |||
158 | 9 | $interlanguageLinksLookup->setStore( $store ); |
|
159 | 9 | $interlanguageLinksLookup->invalidateLookupCache( $title ); |
|
160 | |||
161 | 9 | return true; |
|
162 | }; |
||
163 | |||
164 | /** |
||
165 | * https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete |
||
166 | */ |
||
167 | $this->handlers['SMW::SQLStore::BeforeChangeTitleComplete'] = function ( $store, $oldTitle, $newTitle, $pageid, $redirid ) use ( $interlanguageLinksLookup ) { |
||
168 | |||
169 | 2 | $interlanguageLinksLookup->setStore( $store ); |
|
170 | |||
171 | 2 | $interlanguageLinksLookup->invalidateLookupCache( $oldTitle ); |
|
172 | 2 | $interlanguageLinksLookup->invalidateLookupCache( $newTitle ); |
|
173 | |||
174 | 2 | return true; |
|
175 | }; |
||
176 | |||
177 | /** |
||
178 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge |
||
179 | */ |
||
180 | $this->handlers['ArticlePurge']= function ( &$wikiPage ) use ( $interlanguageLinksLookup ) { |
||
181 | |||
182 | 1 | $interlanguageLinksLookup->invalidateLookupCache( |
|
183 | 1 | $wikiPage->getTitle() |
|
184 | 1 | ); |
|
185 | |||
186 | 1 | return true; |
|
187 | }; |
||
188 | |||
189 | /** |
||
190 | * https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete |
||
191 | */ |
||
192 | $this->handlers['NewRevisionFromEditComplete'] = function ( $wikiPage ) use ( $interlanguageLinksLookup ) { |
||
193 | |||
194 | 9 | $interlanguageLinksLookup->invalidateLookupCache( |
|
195 | 9 | $wikiPage->getTitle() |
|
196 | 9 | ); |
|
197 | |||
198 | 9 | return true; |
|
199 | }; |
||
200 | |||
201 | /** |
||
202 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateGetLanguageLink |
||
203 | */ |
||
204 | $this->handlers['SkinTemplateGetLanguageLink'] = function ( &$languageLink, $languageLinkTitle, $title ) { |
||
205 | |||
206 | 1 | $siteLanguageLinkModifier = new SiteLanguageLinkModifier( |
|
207 | 1 | $languageLinkTitle, |
|
208 | $title |
||
209 | 1 | ); |
|
210 | |||
211 | 1 | $siteLanguageLinkModifier->modifyLanguageLink( $languageLink ); |
|
212 | |||
213 | 1 | return true; |
|
214 | }; |
||
215 | |||
216 | /** |
||
217 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/PageContentLanguage |
||
218 | */ |
||
219 | $this->handlers['PageContentLanguage'] = function ( $title, &$pageLang ) use ( $pageContentLanguageOnTheFlyModifier ) { |
||
220 | |||
221 | 9 | $pageLang = $pageContentLanguageOnTheFlyModifier->getPageContentLanguage( |
|
222 | 9 | $title, |
|
223 | $pageLang |
||
224 | 9 | ); |
|
225 | |||
226 | 9 | return true; |
|
227 | }; |
||
228 | |||
229 | /** |
||
230 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy |
||
231 | */ |
||
232 | $this->handlers['ParserAfterTidy'] = function ( &$parser, &$text ) { |
||
233 | |||
234 | 9 | $parserData = ApplicationFactory::getInstance()->newParserData( |
|
235 | 9 | $parser->getTitle(), |
|
236 | 9 | $parser->getOutput() |
|
237 | 9 | ); |
|
238 | |||
239 | 9 | $languageLinkAnnotator = new LanguageLinkAnnotator( |
|
240 | $parserData |
||
241 | 9 | ); |
|
242 | |||
243 | 9 | $interwikiLanguageLinkFetcher = new InterwikiLanguageLinkFetcher( |
|
244 | $languageLinkAnnotator |
||
245 | 9 | ); |
|
246 | |||
247 | 9 | $interwikiLanguageLinkFetcher->fetchLanguagelinksFromParserOutput( |
|
248 | 9 | $parser->getOutput() |
|
249 | 9 | ); |
|
250 | |||
251 | 9 | return true; |
|
252 | }; |
||
253 | 2 | } |
|
254 | |||
255 | 2 | private function registerSpecialSearchHooks( InterlanguageLinksLookup $interlanguageLinksLookup ) { |
|
327 | |||
328 | } |
||
329 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.