Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / api / ApiHookRunner.php
blob740e13ab2e0368fac5fd87edc8054ca5755ee559
1 <?php
3 namespace MediaWiki\Api;
5 use Article;
6 use MediaWiki\HookContainer\HookContainer;
7 use MediaWiki\Parser\ParserOptions;
8 use MediaWiki\Session\Session;
9 use MediaWiki\User\UserIdentity;
11 /**
12 * This class provides an implementation of the hook interfaces used
13 * by the core Action API, forwarding hook calls to HookContainer for
14 * dispatch to extensions.
16 * To get an instance, use ApiBase::getHookRunner().
18 class ApiHookRunner implements
19 Hook\APIAfterExecuteHook,
20 Hook\ApiCheckCanExecuteHook,
21 Hook\ApiDeprecationHelpHook,
22 Hook\ApiLogFeatureUsageHook,
23 Hook\ApiFeedContributions__feedItemHook,
24 Hook\ApiFormatHighlightHook,
25 Hook\APIGetAllowedParamsHook,
26 Hook\APIGetDescriptionMessagesHook,
27 Hook\APIGetParamDescriptionMessagesHook,
28 Hook\APIHelpModifyOutputHook,
29 Hook\ApiMain__moduleManagerHook,
30 Hook\ApiMain__onExceptionHook,
31 Hook\ApiMakeParserOptionsHook,
32 Hook\ApiMaxLagInfoHook,
33 Hook\ApiOpenSearchSuggestHook,
34 Hook\ApiOptionsHook,
35 Hook\ApiParseMakeOutputPageHook,
36 Hook\APIQueryAfterExecuteHook,
37 Hook\ApiQueryBaseAfterQueryHook,
38 Hook\ApiQueryBaseBeforeQueryHook,
39 Hook\ApiQueryBaseProcessRowHook,
40 Hook\ApiQueryCheckCanExecuteHook,
41 Hook\APIQueryGeneratorAfterExecuteHook,
42 Hook\APIQuerySiteInfoGeneralInfoHook,
43 Hook\APIQuerySiteInfoStatisticsInfoHook,
44 Hook\ApiQueryTokensRegisterTypesHook,
45 Hook\ApiQueryWatchlistExtractOutputDataHook,
46 Hook\ApiQueryWatchlistPrepareWatchedItemQueryServiceOptionsHook,
47 Hook\ApiQuery__moduleManagerHook,
48 Hook\ApiRsdServiceApisHook,
49 Hook\ApiValidatePasswordHook,
50 Hook\RequestHasSameOriginSecurityHook,
51 \MediaWiki\Hook\EditFormPreloadTextHook,
52 \MediaWiki\Hook\FileUndeleteCompleteHook,
53 \MediaWiki\Hook\GetLinkColoursHook,
54 \MediaWiki\Hook\ImportSourcesHook,
55 \MediaWiki\Output\Hook\LanguageLinksHook,
56 \MediaWiki\Output\Hook\OutputPageBeforeHTMLHook,
57 \MediaWiki\Output\Hook\OutputPageCheckLastModifiedHook,
58 \MediaWiki\Page\Hook\ArticleParserOptionsHook,
59 \MediaWiki\Hook\TempUserCreatedRedirectHook,
60 \MediaWiki\Hook\UserLoginCompleteHook,
61 \MediaWiki\Hook\UserLogoutCompleteHook,
62 \MediaWiki\SpecialPage\Hook\ChangeAuthenticationDataAuditHook
64 private HookContainer $container;
66 public function __construct( HookContainer $container ) {
67 $this->container = $container;
70 public function onAPIAfterExecute( $module ) {
71 return $this->container->run(
72 'APIAfterExecute',
73 [ $module ]
77 public function onApiCheckCanExecute( $module, $user, &$message ) {
78 return $this->container->run(
79 'ApiCheckCanExecute',
80 [ $module, $user, &$message ]
84 public function onApiDeprecationHelp( &$msgs ) {
85 return $this->container->run(
86 'ApiDeprecationHelp',
87 [ &$msgs ]
91 public function onApiFeedContributions__feedItem( $row, $context, &$feedItem ) {
92 return $this->container->run(
93 'ApiFeedContributions::feedItem',
94 [ $row, $context, &$feedItem ]
98 public function onApiFormatHighlight( $context, $text, $mime, $format ) {
99 return $this->container->run(
100 'ApiFormatHighlight',
101 [ $context, $text, $mime, $format ]
105 public function onAPIGetAllowedParams( $module, &$params, $flags ) {
106 return $this->container->run(
107 'APIGetAllowedParams',
108 [ $module, &$params, $flags ]
112 public function onAPIGetDescriptionMessages( $module, &$msg ) {
113 return $this->container->run(
114 'APIGetDescriptionMessages',
115 [ $module, &$msg ]
119 public function onAPIGetParamDescriptionMessages( $module, &$msg ) {
120 return $this->container->run(
121 'APIGetParamDescriptionMessages',
122 [ $module, &$msg ]
126 public function onAPIHelpModifyOutput( $module, &$help, $options, &$tocData ) {
127 return $this->container->run(
128 'APIHelpModifyOutput',
129 [ $module, &$help, $options, &$tocData ]
133 public function onApiLogFeatureUsage( $feature, array $clientInfo ): void {
134 $this->container->run(
135 'ApiLogFeatureUsage',
136 [ $feature, $clientInfo ]
140 public function onApiMain__moduleManager( $moduleManager ) {
141 return $this->container->run(
142 'ApiMain::moduleManager',
143 [ $moduleManager ]
147 public function onApiMain__onException( $apiMain, $e ) {
148 return $this->container->run(
149 'ApiMain::onException',
150 [ $apiMain, $e ]
154 public function onApiMakeParserOptions( $options, $title, $params, $module,
155 &$reset, &$suppressCache
157 return $this->container->run(
158 'ApiMakeParserOptions',
159 [ $options, $title, $params, $module, &$reset, &$suppressCache ]
163 public function onApiMaxLagInfo( &$lagInfo ): void {
164 $this->container->run(
165 'ApiMaxLagInfo',
166 [ &$lagInfo ],
167 [ 'abortable' => false ]
171 public function onApiOpenSearchSuggest( &$results ) {
172 return $this->container->run(
173 'ApiOpenSearchSuggest',
174 [ &$results ]
178 public function onApiOptions( $apiModule, $user, $changes, $resetKinds ) {
179 return $this->container->run(
180 'ApiOptions',
181 [ $apiModule, $user, $changes, $resetKinds ]
185 public function onApiParseMakeOutputPage( $module, $output ) {
186 return $this->container->run(
187 'ApiParseMakeOutputPage',
188 [ $module, $output ]
192 public function onAPIQueryAfterExecute( $module ) {
193 return $this->container->run(
194 'APIQueryAfterExecute',
195 [ $module ]
199 public function onApiQueryBaseAfterQuery( $module, $result, &$hookData ) {
200 return $this->container->run(
201 'ApiQueryBaseAfterQuery',
202 [ $module, $result, &$hookData ]
206 public function onApiQueryBaseBeforeQuery( $module, &$tables, &$fields,
207 &$conds, &$query_options, &$join_conds, &$hookData
209 return $this->container->run(
210 'ApiQueryBaseBeforeQuery',
211 [ $module, &$tables, &$fields, &$conds, &$query_options,
212 &$join_conds, &$hookData ]
216 public function onApiQueryBaseProcessRow( $module, $row, &$data, &$hookData ) {
217 return $this->container->run(
218 'ApiQueryBaseProcessRow',
219 [ $module, $row, &$data, &$hookData ]
223 public function onApiQueryCheckCanExecute( $modules, $authority, &$message ) {
224 return $this->container->run(
225 'ApiQueryCheckCanExecute',
226 [ $modules, $authority, &$message ]
230 public function onAPIQueryGeneratorAfterExecute( $module, $resultPageSet ) {
231 return $this->container->run(
232 'APIQueryGeneratorAfterExecute',
233 [ $module, $resultPageSet ]
237 public function onAPIQuerySiteInfoGeneralInfo( $module, &$results ) {
238 return $this->container->run(
239 'APIQuerySiteInfoGeneralInfo',
240 [ $module, &$results ]
244 public function onAPIQuerySiteInfoStatisticsInfo( &$results ) {
245 return $this->container->run(
246 'APIQuerySiteInfoStatisticsInfo',
247 [ &$results ]
251 public function onApiQueryTokensRegisterTypes( &$salts ) {
252 return $this->container->run(
253 'ApiQueryTokensRegisterTypes',
254 [ &$salts ]
258 public function onApiQueryWatchlistExtractOutputData( $module, $watchedItem,
259 $recentChangeInfo, &$vals
261 return $this->container->run(
262 'ApiQueryWatchlistExtractOutputData',
263 [ $module, $watchedItem, $recentChangeInfo, &$vals ]
267 public function onApiQueryWatchlistPrepareWatchedItemQueryServiceOptions(
268 $module, $params, &$options
270 return $this->container->run(
271 'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions',
272 [ $module, $params, &$options ]
276 public function onApiQuery__moduleManager( $moduleManager ) {
277 return $this->container->run(
278 'ApiQuery::moduleManager',
279 [ $moduleManager ]
283 public function onApiRsdServiceApis( &$apis ) {
284 return $this->container->run(
285 'ApiRsdServiceApis',
286 [ &$apis ]
290 public function onApiValidatePassword( $module, &$r ) {
291 return $this->container->run(
292 'ApiValidatePassword',
293 [ $module, &$r ]
297 public function onArticleParserOptions( Article $article, ParserOptions $popts ) {
298 return $this->container->run(
299 'ArticleParserOptions',
300 [ $article, $popts ]
304 public function onChangeAuthenticationDataAudit( $req, $status ) {
305 return $this->container->run(
306 'ChangeAuthenticationDataAudit',
307 [ $req, $status ]
311 public function onEditFormPreloadText( &$text, $title ) {
312 return $this->container->run(
313 'EditFormPreloadText',
314 [ &$text, $title ]
318 public function onFileUndeleteComplete( $title, $fileVersions, $user, $reason ) {
319 return $this->container->run(
320 'FileUndeleteComplete',
321 [ $title, $fileVersions, $user, $reason ]
325 public function onGetLinkColours( $pagemap, &$classes, $title ) {
326 return $this->container->run(
327 'GetLinkColours',
328 [ $pagemap, &$classes, $title ]
332 public function onImportSources( &$importSources ) {
333 return $this->container->run(
334 'ImportSources',
335 [ &$importSources ]
339 public function onLanguageLinks( $title, &$links, &$linkFlags ) {
340 return $this->container->run(
341 'LanguageLinks',
342 [ $title, &$links, &$linkFlags ]
346 public function onOutputPageBeforeHTML( $out, &$text ) {
347 return $this->container->run(
348 'OutputPageBeforeHTML',
349 [ $out, &$text ]
353 public function onOutputPageCheckLastModified( &$modifiedTimes, $out ) {
354 return $this->container->run(
355 'OutputPageCheckLastModified',
356 [ &$modifiedTimes, $out ]
360 public function onRequestHasSameOriginSecurity( $request ) {
361 return $this->container->run(
362 'RequestHasSameOriginSecurity',
363 [ $request ]
367 public function onTempUserCreatedRedirect(
368 Session $session,
369 UserIdentity $user,
370 string $returnTo,
371 string $returnToQuery,
372 string $returnToAnchor,
373 &$redirectUrl
375 return $this->container->run(
376 'TempUserCreatedRedirect',
377 [ $session, $user, $returnTo, $returnToQuery, $returnToAnchor, &$redirectUrl ]
381 public function onUserLoginComplete( $user, &$inject_html, $direct ) {
382 return $this->container->run(
383 'UserLoginComplete',
384 [ $user, &$inject_html, $direct ]
388 public function onUserLogoutComplete( $user, &$inject_html, $oldName ) {
389 return $this->container->run(
390 'UserLogoutComplete',
391 [ $user, &$inject_html, $oldName ]