* @ingroup Parser
*/
use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\Linker\LinkRendererFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\Special\SpecialPageFactory;
use Wikimedia\ScopedCallback;
/** @var Config */
private $siteConfig;
+ /** @var LinkRendererFactory */
+ private $linkRendererFactory;
+
/**
* @param array $parserConf See $wgParserConf documentation
* @param MagicWordFactory|null $magicWordFactory
* @param string|null $urlProtocols As returned from wfUrlProtocols()
* @param SpecialPageFactory|null $spFactory
* @param Config|null $siteConfig
+ * @param LinkRendererFactory|null $linkRendererFactory
*/
public function __construct(
array $parserConf = [], MagicWordFactory $magicWordFactory = null,
Language $contLang = null, ParserFactory $factory = null, $urlProtocols = null,
- SpecialPageFactory $spFactory = null, Config $siteConfig = null
+ SpecialPageFactory $spFactory = null, Config $siteConfig = null,
+ LinkRendererFactory $linkRendererFactory = null
) {
$this->mConf = $parserConf;
$this->mUrlProtocols = $urlProtocols ?? wfUrlProtocols();
$this->factory = $factory ?? $services->getParserFactory();
$this->specialPageFactory = $spFactory ?? $services->getSpecialPageFactory();
$this->siteConfig = $siteConfig ?? MediaWikiServices::getInstance()->getMainConfig();
+
+ $this->linkRendererFactory =
+ $linkRendererFactory ?? MediaWikiServices::getInstance()->getLinkRendererFactory();
}
/**
* @return LinkRenderer
*/
public function getLinkRenderer() {
+ // XXX We make the LinkRenderer with current options and then cache it forever
if ( !$this->mLinkRenderer ) {
- $this->mLinkRenderer = MediaWikiServices::getInstance()
- ->getLinkRendererFactory()->create();
+ $this->mLinkRenderer = $this->linkRendererFactory->create();
$this->mLinkRenderer->setStubThreshold(
$this->getOptions()->getStubThreshold()
);
* @file
* @ingroup Parser
*/
+use MediaWiki\Linker\LinkRendererFactory;
use MediaWiki\Special\SpecialPageFactory;
/** @var Config */
private $siteConfig;
+ /** @var LinkRendererFactory */
+ private $linkRendererFactory;
+
/**
* @param array $parserConf See $wgParserConf documentation
* @param MagicWordFactory $magicWordFactory
* @param string $urlProtocols As returned from wfUrlProtocols()
* @param SpecialPageFactory $spFactory
* @param Config $siteConfig
+ * @param LinkRendererFactory $linkRendererFactory
* @since 1.32
*/
public function __construct(
array $parserConf, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols,
- SpecialPageFactory $spFactory, Config $siteConfig
+ SpecialPageFactory $spFactory, Config $siteConfig, LinkRendererFactory $linkRendererFactory
) {
$this->parserConf = $parserConf;
$this->magicWordFactory = $magicWordFactory;
$this->urlProtocols = $urlProtocols;
$this->specialPageFactory = $spFactory;
$this->siteConfig = $siteConfig;
+ $this->linkRendererFactory = $linkRendererFactory;
}
/**
*/
public function create() : Parser {
return new Parser( $this->parserConf, $this->magicWordFactory, $this->contLang, $this,
- $this->urlProtocols, $this->specialPageFactory, $this->siteConfig );
+ $this->urlProtocols, $this->specialPageFactory, $this->siteConfig,
+ $this->linkRendererFactory );
}
}