MediaWiki REL1_34
ParserFactory.php
Go to the documentation of this file.
1<?php
27use Psr\Log\LoggerInterface;
28use Psr\Log\NullLogger;
29
35 private $svcOptions;
36
39
41 private $contLang;
42
45
48
51
53 private $nsInfo;
54
56 private $logger;
57
60
87 public function __construct(
88 $svcOptions,
89 MagicWordFactory $magicWordFactory,
90 Language $contLang,
91 $urlProtocols,
92 SpecialPageFactory $spFactory,
93 $linkRendererFactory,
94 $nsInfo = null,
95 $logger = null,
96 BadFileLookup $badFileLookup = null
97 ) {
98 // @todo Do we need to retain compat for constructing this class directly?
99 if ( !$nsInfo ) {
100 wfDeprecated( __METHOD__ . ' with no NamespaceInfo argument', '1.34' );
101 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
102 }
103 if ( $linkRendererFactory instanceof Config ) {
104 // Old calling convention had an array in the format of $wgParserConf as the first
105 // parameter, and a Config as the sixth, with LinkRendererFactory as the seventh.
106 wfDeprecated( __METHOD__ . ' with Config parameter', '1.34' );
107 $svcOptions = new ServiceOptions( Parser::$constructorOptions,
109 [ 'class' => Parser::class,
110 'preprocessorClass' => Parser::getDefaultPreprocessorClass() ],
111 func_get_arg( 5 )
112 );
113 $linkRendererFactory = func_get_arg( 6 );
114 $nsInfo = func_num_args() > 7 ? func_get_arg( 7 ) : null;
115 }
116 $svcOptions->assertRequiredOptions( Parser::$constructorOptions );
117
118 wfDebug( __CLASS__ . ": using preprocessor: {$svcOptions->get( 'preprocessorClass' )}\n" );
119
120 $this->svcOptions = $svcOptions;
121 $this->magicWordFactory = $magicWordFactory;
122 $this->contLang = $contLang;
123 $this->urlProtocols = $urlProtocols;
124 $this->specialPageFactory = $spFactory;
125 $this->linkRendererFactory = $linkRendererFactory;
126 $this->nsInfo = $nsInfo;
127 $this->logger = $logger ?: new NullLogger();
128 $this->badFileLookup = $badFileLookup ??
129 MediaWikiServices::getInstance()->getBadFileLookup();
130 }
131
136 public function create() : Parser {
137 return new Parser(
138 $this->svcOptions,
139 $this->magicWordFactory,
140 $this->contLang,
141 $this,
142 $this->urlProtocols,
143 $this->specialPageFactory,
144 $this->linkRendererFactory,
145 $this->nsInfo,
146 $this->logger,
147 $this->badFileLookup
148 );
149 }
150}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
Definition Language.php:37
A factory that stores information about MagicWords, and creates them on demand with caching.
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Factory to create LinkRender objects.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Factory for handling the special page list and generating SpecialPage objects.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Language $contLang
SpecialPageFactory $specialPageFactory
LoggerInterface $logger
LinkRendererFactory $linkRendererFactory
MagicWordFactory $magicWordFactory
ServiceOptions $svcOptions
BadFileLookup $badFileLookup
NamespaceInfo $nsInfo
__construct( $svcOptions, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols, SpecialPageFactory $spFactory, $linkRendererFactory, $nsInfo=null, $logger=null, BadFileLookup $badFileLookup=null)
Old parameter list, which we support for backwards compatibility, were: array $parserConf See $wgPars...
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:74
return[ 'OATHAuth'=> function(MediaWikiServices $services) { return new OATHAuth($services->getMainConfig(), $services->getDBLoadBalancerFactory());}, 'OATHUserRepository'=> function(MediaWikiServices $services) { global $wgOATHAuthDatabase;$auth=$services->getService( 'OATHAuth');return new OATHUserRepository($services->getDBLoadBalancerFactory() ->getMainLB( $wgOATHAuthDatabase), new \HashBagOStuff(['maxKey'=> 5]), $auth);}]
Interface for configuration instances.
Definition Config.php:28