MediaWiki 1.42.1
ApiModuleManager Class Reference

This class holds a list of modules and handles instantiation. More...

Inherits MediaWiki\Context\ContextSource.

Collaboration diagram for ApiModuleManager:

Public Member Functions

 __construct (ApiBase $parentModule, ObjectFactory $objectFactory=null)
 Construct new module manager.
 
 addModule ( $name, $group, $spec, $factory=null)
 Add or overwrite a module in this ApiMain instance.
 
 addModules (array $modules, $group)
 Add a list of modules to the manager.
 
 getClassName ( $module)
 Returns the class name of the given module.
 
 getGroups ()
 Get a list of groups this manager contains.
 
 getModule ( $moduleName, $group=null, $ignoreCache=false)
 Get module instance by name, or instantiate it if it does not exist.
 
 getModuleGroup ( $moduleName)
 Returns the group name for the given module.
 
 getNames ( $group=null)
 Get an array of modules in a specific group or all if no group is set.
 
 getNamesWithClasses ( $group=null)
 Create an array of (moduleName => moduleClass) for a specific group or for all.
 
 isDefined ( $moduleName, $group=null)
 Returns true if the specific module is defined at all or in a specific group.
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Detailed Description

This class holds a list of modules and handles instantiation.

Since
1.21

Definition at line 34 of file ApiModuleManager.php.

Constructor & Destructor Documentation

◆ __construct()

ApiModuleManager::__construct ( ApiBase $parentModule,
ObjectFactory $objectFactory = null )

Construct new module manager.

Parameters
ApiBase$parentModuleParent module instance will be used during instantiation
ObjectFactory | null$objectFactoryObject factory to use when instantiating modules

Definition at line 63 of file ApiModuleManager.php.

Member Function Documentation

◆ addModule()

ApiModuleManager::addModule ( $name,
$group,
$spec,
$factory = null )

Add or overwrite a module in this ApiMain instance.

Intended for use by extending classes who wish to add their own modules to their lexicon or override the behavior of inherent ones.

ObjectFactory is used to instantiate the module when needed. The parent module ($parentModule from __construct()) and the $name are passed as extraArgs.

Since
1.34, accepts an ObjectFactory spec as the third parameter. The old calling convention, passing a class name as parameter #3 and an optional factory callable as parameter #4, is deprecated.
Parameters
string$nameThe identifier for this module.
string$groupName of the module group
string | array$specThe ObjectFactory spec for instantiating the module, or a class name to instantiate.
callable | null$factoryCallback for instantiating the module (deprecated).
Exceptions
InvalidArgumentException

Definition at line 103 of file ApiModuleManager.php.

References wfDeprecated().

Referenced by addModules().

◆ addModules()

ApiModuleManager::addModules ( array $modules,
$group )

Add a list of modules to the manager.

Each module is described by an ObjectFactory spec.

This simply calls addModule() for each module in $modules.

See also
ApiModuleManager::addModule()
Parameters
array$modulesA map of ModuleName => ModuleSpec
string$groupWhich group modules belong to (action,format,...)

Definition at line 78 of file ApiModuleManager.php.

References addModule().

◆ getClassName()

ApiModuleManager::getClassName ( $module)

Returns the class name of the given module.

Parameters
string$moduleModule name
Returns
string|false class name or false if the module does not exist
Since
1.24

Definition at line 231 of file ApiModuleManager.php.

◆ getGroups()

ApiModuleManager::getGroups ( )

Get a list of groups this manager contains.

Returns
array

Definition at line 270 of file ApiModuleManager.php.

◆ getModule()

ApiModuleManager::getModule ( $moduleName,
$group = null,
$ignoreCache = false )

Get module instance by name, or instantiate it if it does not exist.

Parameters
string$moduleName
string | null$groupOptionally validate that the module is in a specific group
bool$ignoreCacheIf true, force-creates a new instance and does not cache it
Returns
ApiBase|null The new module instance, or null if failed

Definition at line 140 of file ApiModuleManager.php.

◆ getModuleGroup()

ApiModuleManager::getModuleGroup ( $moduleName)

Returns the group name for the given module.

Parameters
string$moduleName
Returns
string|null Group name or null if missing

Definition at line 258 of file ApiModuleManager.php.

◆ getNames()

ApiModuleManager::getNames ( $group = null)

Get an array of modules in a specific group or all if no group is set.

Parameters
string | null$groupOptional group filter
Returns
string[] List of module names

Definition at line 194 of file ApiModuleManager.php.

◆ getNamesWithClasses()

ApiModuleManager::getNamesWithClasses ( $group = null)

Create an array of (moduleName => moduleClass) for a specific group or for all.

Parameters
string | null$groupName of the group to get or null for all
Returns
array Name=>class map

Definition at line 213 of file ApiModuleManager.php.

◆ isDefined()

ApiModuleManager::isDefined ( $moduleName,
$group = null )

Returns true if the specific module is defined at all or in a specific group.

Parameters
string$moduleName
string | null$groupGroup name to check against, or null to check all groups,
Returns
bool True if defined

Definition at line 245 of file ApiModuleManager.php.


The documentation for this class was generated from the following file: