MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/190140

Change subject: New hook ApiMain::moduleManager
......................................................................

New hook ApiMain::moduleManager

Needed to conditionally register API modules. The previous way, messing with 
globals
from extension functions, is getting problematic because Config class will make 
this
impossible.

Change-Id: I86b40aeec555dd6b3cd82cab31d96e85fdf0a665
---
M RELEASE-NOTES-1.25
M docs/hooks.txt
M includes/api/ApiMain.php
3 files changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/40/190140/1

diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 3f24db0..7ee2b64 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -97,6 +97,8 @@
   tags.
 * Added 'ChangeTagsListActive' hook, to separate the concepts of "defined" and
   "active" formerly conflated by the 'ListDefinedTags' hook.
+* New hook "ApiMain::moduleManager", can be used for conditional registration 
of API
+  modules.
 
 ==== External libraries ====
 * MediaWiki now requires certain external libraries to be installed. In the 
past
diff --git a/docs/hooks.txt b/docs/hooks.txt
index f47890d..b7d8085 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -418,6 +418,10 @@
 &$help: Array of HTML strings to be joined for the output.
 $options: Array Options passed to ApiHelp::getHelp
 
+'ApiMain::moduleManager': Called when APiMain has finished initializing its
+module manager. Can be used to conditionally register API modules.
+$moduleManager: ApiModuleManager Module manager instance
+
 'ApiOpenSearchSuggest': Called when constructing the OpenSearch results. Hooks
 can alter or append to the array.
 &$results: array with integer keys to associative arrays. Keys in associative
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index f17b874..47a8057 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -214,6 +214,8 @@
                $this->mModuleMgr->addModules( self::$Formats, 'format' );
                $this->mModuleMgr->addModules( $config->get( 'APIFormatModules' 
), 'format' );
 
+               Hooks::run( 'ApiMain::moduleManager', array( $this->mModuleMgr 
) );
+
                $this->mResult = new ApiResult( $this );
                $this->mEnableWrite = $enableWrite;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/190140
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86b40aeec555dd6b3cd82cab31d96e85fdf0a665
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to