*/
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MediaWikiServices;
+use MediaWiki\Special\SpecialPageFactory;
use Wikimedia\ScopedCallback;
/**
/** @var ParserFactory */
private $factory;
+ /** @var SpecialPageFactory */
+ private $specialPageFactory;
+
/**
* @param array $conf See $wgParserConf documentation
* @param MagicWordFactory|null $magicWordFactory
* @param Language|null $contLang Content language
* @param ParserFactory|null $factory
* @param string|null $urlProtocols As returned from wfUrlProtocols()
+ * @param SpecialPageFactory|null $spFactory
*/
public function __construct(
array $conf = [], MagicWordFactory $magicWordFactory = null, Language $contLang = null,
- ParserFactory $factory = null, $urlProtocols = null
+ ParserFactory $factory = null, $urlProtocols = null, SpecialPageFactory $spFactory = null
) {
$this->mConf = $conf;
$this->mUrlProtocols = $urlProtocols ?? wfUrlProtocols();
}
wfDebug( __CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n" );
+ $services = MediaWikiServices::getInstance();
$this->magicWordFactory = $magicWordFactory ??
- MediaWikiServices::getInstance()->getMagicWordFactory();
+ $services->getMagicWordFactory();
- $this->contLang = $contLang ?? MediaWikiServices::getInstance()->getContentLanguage();
+ $this->contLang = $contLang ?? $services->getContentLanguage();
- $this->factory = $factory ?? MediaWikiServices::getInstance()->getParserFactory();
+ $this->factory = $factory ?? $services->getParserFactory();
+ $this->specialPageFactory = $spFactory ?? $services->getSpecialPageFactory();
}
/**
&& $this->mOptions->getAllowSpecialInclusion()
&& $this->ot['html']
) {
- $specialPage = SpecialPageFactory::getPage( $title->getDBkey() );
+ $specialPage = $this->specialPageFactory->getPage( $title->getDBkey() );
// Pass the template arguments as URL parameters.
// "uselang" will have no effect since the Language object
// is forced to the one defined in ParserOptions.
$context->setUser( User::newFromName( '127.0.0.1', false ) );
}
$context->setLanguage( $this->mOptions->getUserLangObj() );
- $ret = SpecialPageFactory::capturePath(
- $title, $context, $this->getLinkRenderer() );
+ $ret = $this->specialPageFactory->capturePath( $title, $context, $this->getLinkRenderer() );
if ( $ret ) {
$text = $context->getOutput()->getHTML();
$this->mOutput->addOutputPageMetadata( $context->getOutput() );
<?php
-
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* @ingroup Parser
*/
+use MediaWiki\Special\SpecialPageFactory;
+
/**
* @since 1.32
*/
/** @var string */
private $urlProtocols;
+ /** @var SpecialPageFactory */
+ private $specialPageFactory;
+
/**
* @param array $conf See $wgParserConf documentation
* @param MagicWordFactory $magicWordFactory
* @param Language $contLang Content language
* @param string $urlProtocols As returned from wfUrlProtocols()
+ * @param SpecialPageFactory $spFactory
* @since 1.32
*/
public function __construct(
- array $conf, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols
+ array $conf, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols,
+ SpecialPageFactory $spFactory
) {
$this->conf = $conf;
$this->magicWordFactory = $magicWordFactory;
$this->contLang = $contLang;
$this->urlProtocols = $urlProtocols;
+ $this->specialPageFactory = $spFactory;
}
/**
*/
public function create() : Parser {
return new Parser( $this->conf, $this->magicWordFactory, $this->contLang, $this,
- $this->urlProtocols );
+ $this->urlProtocols, $this->specialPageFactory );
}
}