MediaWiki
1.30.0
|
This class holds a list of modules and handles instantiation. More...
Public Member Functions | |
__construct (ApiBase $parentModule) | |
Construct new module manager. More... | |
addModule ( $name, $group, $class, $factory=null) | |
Add or overwrite a module in this ApiMain instance. More... | |
addModules (array $modules, $group) | |
Add a list of modules to the manager. More... | |
getClassName ( $module) | |
Returns the class name of the given module. More... | |
getGroups () | |
Get a list of groups this manager contains. More... | |
getModule ( $moduleName, $group=null, $ignoreCache=false) | |
Get module instance by name, or instantiate it if it does not exist. More... | |
getModuleGroup ( $moduleName) | |
Returns the group name for the given module. More... | |
getNames ( $group=null) | |
Get an array of modules in a specific group or all if no group is set. More... | |
getNamesWithClasses ( $group=null) | |
Create an array of (moduleName => moduleClass) for a specific group or for all. More... | |
isDefined ( $moduleName, $group=null) | |
Returns true if the specific module is defined at all or in a specific group. More... | |
Public Member Functions inherited from ContextSource | |
canUseWikiPage () | |
Check whether a WikiPage object can be get with getWikiPage(). More... | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. More... | |
getConfig () | |
Get the Config object. More... | |
getContext () | |
Get the base IContextSource object. More... | |
getLanguage () | |
Get the Language object. More... | |
getOutput () | |
Get the OutputPage object. More... | |
getRequest () | |
Get the WebRequest object. More... | |
getSkin () | |
Get the Skin object. More... | |
getStats () | |
Get the Stats object. More... | |
getTiming () | |
Get the Timing object. More... | |
getTitle () | |
Get the Title object. More... | |
getUser () | |
Get the User object. More... | |
getWikiPage () | |
Get the WikiPage object. More... | |
msg ( $key) | |
Get a Message object with context set Parameters are the same as wfMessage() More... | |
setContext (IContextSource $context) | |
Set the IContextSource object. More... | |
Private Member Functions | |
instantiateModule ( $name, $class, $factory=null) | |
Instantiate the module using the given class or factory function. More... | |
Private Attributes | |
null[] | $mGroups = [] |
ApiBase[] | $mInstances = [] |
array[] | $mModules = [] |
ApiBase | $mParent |
This class holds a list of modules and handles instantiation.
Definition at line 34 of file ApiModuleManager.php.
ApiModuleManager::__construct | ( | ApiBase | $parentModule | ) |
Construct new module manager.
ApiBase | $parentModule | Parent module instance will be used during instantiation |
Definition at line 57 of file ApiModuleManager.php.
ApiModuleManager::addModule | ( | $name, | |
$group, | |||
$class, | |||
$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.
string | $name | The identifier for this module. |
string | $group | Name of the module group |
string | $class | The class where this module is implemented. |
callable | null | $factory | Callback for instantiating the module. |
InvalidArgumentException |
Definition at line 125 of file ApiModuleManager.php.
References $name.
Referenced by addModules().
ApiModuleManager::addModules | ( | array | $modules, |
$group | |||
) |
Add a list of modules to the manager.
Each module is described by a module spec.
Each module spec is an associative array containing at least the 'class' key for the module's class, and optionally a 'factory' key for the factory function to use for the module.
That factory function will be called with two parameters, the parent module (an instance of ApiBase, usually ApiMain) and the name the module was registered under. The return value must be an instance of the class given in the 'class' field.
For backward compatibility, the module spec may also be a simple string containing the module's class name. In that case, the class' constructor will be called with the parent module and module name as parameters, as described above.
Examples for defining module specs:
array | $modules | A map of ModuleName => ModuleSpec; The ModuleSpec is either a string containing the module's class name, or an associative array (see above for details). |
string | $group | Which group modules belong to (action,format,...) |
Definition at line 99 of file ApiModuleManager.php.
References $modules, $name, addModule(), and as.
ApiModuleManager::getClassName | ( | $module | ) |
Returns the class name of the given module.
string | $module | Module name |
Definition at line 252 of file ApiModuleManager.php.
ApiModuleManager::getGroups | ( | ) |
Get a list of groups this manager contains.
Definition at line 291 of file ApiModuleManager.php.
ApiModuleManager::getModule | ( | $moduleName, | |
$group = null , |
|||
$ignoreCache = false |
|||
) |
Get module instance by name, or instantiate it if it does not exist.
string | $moduleName | Module name |
string | $group | Optionally validate that the module is in a specific group |
bool | $ignoreCache | If true, force-creates a new instance and does not cache it |
Definition at line 155 of file ApiModuleManager.php.
References instantiateModule(), and list.
Referenced by ApiStructureTest\getSubModulePaths().
ApiModuleManager::getModuleGroup | ( | $moduleName | ) |
Returns the group name for the given module.
string | $moduleName |
Definition at line 279 of file ApiModuleManager.php.
ApiModuleManager::getNames | ( | $group = null | ) |
Get an array of modules in a specific group or all if no group is set.
string | $group | Optional group filter |
Definition at line 215 of file ApiModuleManager.php.
Referenced by ApiStructureTest\getSubModulePaths().
ApiModuleManager::getNamesWithClasses | ( | $group = null | ) |
Create an array of (moduleName => moduleClass) for a specific group or for all.
string | $group | Name of the group to get or null for all |
Definition at line 234 of file ApiModuleManager.php.
|
private |
Instantiate the module using the given class or factory function.
string | $name | The identifier for this module. |
string | $class | The class where this module is implemented. |
callable | null | $factory | Callback for instantiating the module. |
MWException |
Definition at line 192 of file ApiModuleManager.php.
References $name.
Referenced by getModule().
ApiModuleManager::isDefined | ( | $moduleName, | |
$group = null |
|||
) |
Returns true if the specific module is defined at all or in a specific group.
string | $moduleName | Module name |
string | $group | Group name to check against, or null to check all groups, |
Definition at line 266 of file ApiModuleManager.php.
|
private |
Definition at line 47 of file ApiModuleManager.php.
|
private |
Definition at line 43 of file ApiModuleManager.php.
|
private |
Definition at line 51 of file ApiModuleManager.php.
|
private |
Definition at line 39 of file ApiModuleManager.php.