Manual:$wgParser
Jump to navigation
Jump to search
![]() | この機能は廃止予定であるため使用してはいけませんが、後方互換性のためまだ利用できる状態です。 この機能はバージョン 1.32.0 で廃止予定になりました。 |
グローバル オブジェクト: $wgParser | |
---|---|
パーサー オブジェクト | |
廃止予定になった時点のバージョン: | 1.32.0 |
クラス: | Parser |
場所: | Parser.php |
説明
Use MediaWikiServices::getInstance()->getParser() instead (phab:T160811).
The Parser object is responsible for parsing the tags and wikitext contained in wiki pages. Parser extensions hooks are also registered in the Parser object.
Mode of Operation
$wgParser
は、includes/Setup.php
で以下のコードで呼び出されます:
$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
StubObject は includes/StubObject.php
で定義されています。
wgParserConf は、includes/DefaultSettings.php
で以下のコードで定義されています:
$wgParserConf = array('class' => 'Parser',);
Replacement
MediaWiki バージョン: | ≧ 1.32 |
New code should use dependency injection instead.
The parser is now available in the service locator under the Parser
service.
Existing code that has not yet been changed to use dependency injection can call the service locator directly:
public function render() {
$parser = \MediaWiki\MediaWikiServices::getInstance()->getParser();
$text = $parser->parse(
...
)->getText();
}