Manual:$wgExtensionFunctions

From MediaWiki.org
Jump to: navigation, search
Extensions: $wgExtensionFunctions
A list of callback functions which are called once MediaWiki is fully initialised.
Introduced in version: 1.3.0 (r3583)
Removed in version: still in use
Allowed values:
Default value: array()

Other settings: Alphabetical | By Function


[edit] Details

This variable is an array that stores functions to be called after most of MediaWiki initialization is complete. It should be used for final step of initialization of extension setup code that needs to perform advanced things, like using global functions and instantiating autoloaded classes. Typically each extension has one setup function associated with it. The array element concerned is typically defined in the extension file itself, with a statement of the form compatible with call_user_func PHP function:


$wgExtensionFunctions[] = "functionName";
$wgExtensionFunctions[] = array( $classInstance, 'functionName' );
$wgExtensionFunctions[] = array( 'ClassName', 'staticFunctionName' );
$wgExtensionFunctions[] = 'ClassName::staticFunctionName'; // NOT recommended, works only for newer PHP versions

Each setup function is then called from /includes/Setup.php.

For example, if your extension needs to access database during its initialization:


function initMyExtension() {
      $dbr = wfGetDB( DB_SLAVE );
      $myExtension = new MyExtension();
      $myExtension->loadSettingsFromDatabase( $dbr );
}


[edit] See also

Language: English  • 日本語
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox