Manual:$wgExtensionFunctions/zh
From Linux Web Expert
<translate> Extensions</translate>: $wgExtensionFunctions | |
---|---|
MediaWiki完全初始化后调用的回调函数列表。 |
|
<translate> Introduced in version:</translate> | 1.3.0 (r3583) |
<translate> Removed in version:</translate> | <translate> still in use</translate> |
<translate> Allowed values:</translate> | <translate> Unspecified</translate> |
<translate> Default value:</translate> | [] |
<translate> Other settings:</translate> <translate> Alphabetical</translate> | <translate> By function</translate> |
详细信息
一般来说,使用此功能是一种非常规手段,表明MediaWiki核心或扩展中的某个地方可能有设计问题。应该避免这种情况。
该变量是存储在大多数MediaWiki初始化完成后要调用的函数的数组。 Extensions can register callbacks to be executed this way using the ExtensionFunctions of extension.json. At the time these callbacks are called, MediaWikiServices and the main RequestContext are fully initialized.
另请注意,某些配置变量此时可能已经被处理,更改它们可能不安全。 Extensions that need to dynamically set configuration should use a registration callback instead.
ExtensionFunction callbacks should be used only for initialization code that need to interact with service objects as a final step.
例如,如果您的扩展在初始化期间需要访问数据库:
function initMyExtension() {
$dbr = MediaWikiServices::getInstance()
->getConnectionProvider->getReplicaDatabase();
$myExtension = new MyExtension();
$myExtension->loadSettingsFromDatabase( $dbr );
}