Manual:$wgParser/pt-br

Category:Global object variables/pt-br#Parser Category:MediaWiki deprecated or obsolete features/pt-br#Parser

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 do 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();
}
Category:Global object variables/pt-br Category:MediaWiki deprecated or obsolete features/pt-br