Manual:$wgParser

From mediawiki.org
This page is a translated version of the page Manual:$wgParser and the translation is 43% complete.
Outdated translations are marked like this.

Descrição

O objeto Parser é responsável por analisar as tags e o wiki texto contidos nas páginas wiki. Hooks de extensões Parser também são registrados no objeto Parser. Parser extensions hooks are also registered in the Parser object.

Use MediaWikiServices::getInstance()->getParser() instead (phab:T160811).

Modo de Operação

$wgParser é chamado na linha includes/Setup.php com o seguinte código:

$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );

StubObject é definido no arquivo includes/StubObject.php.

wgParserConf é definido em includes/DefaultSettings.php com o seguinte código:

$wgParserConf = array('class' => 'Parser',);

Replacement

Versão 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();
}