* @ingroup Maintenance
*/
+use MediaWiki\MediaWikiServices;
+
require_once __DIR__ . '/Maintenance.php';
/**
*
* @ingroup Maintenance
*/
-class MaintenanceFormatInstallDoc extends Maintenance {
+class FormatInstallDoc extends Maintenance {
function __construct() {
parent::__construct();
$this->addArg( 'path', 'The file name to format', false );
$fileName = $this->getArg( 0 );
$inFile = fopen( $fileName, 'r' );
if ( !$inFile ) {
- $this->error( "Unable to open input file \"$fileName\"" );
- exit( 1 );
+ $this->fatalError( "Unable to open input file \"$fileName\"" );
}
} else {
$inFile = STDIN;
$fileName = $this->getOption( 'outfile' );
$outFile = fopen( $fileName, 'w' );
if ( !$outFile ) {
- $this->error( "Unable to open output file \"$fileName\"" );
- exit( 1 );
+ $this->fatalError( "Unable to open output file \"$fileName\"" );
}
} else {
$outFile = STDOUT;
$outText = InstallDocFormatter::format( $inText );
if ( $this->hasOption( 'html' ) ) {
- global $wgParser;
+ $parser = MediaWikiServices::getInstance()->getParser();
$opt = new ParserOptions;
$title = Title::newFromText( 'Text file' );
- $out = $wgParser->parse( $outText, $title, $opt );
+ $out = $parser->parse( $outText, $title, $opt );
$outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
}
}
}
-$maintClass = 'MaintenanceFormatInstallDoc';
+$maintClass = FormatInstallDoc::class;
require_once RUN_MAINTENANCE_IF_MAIN;