MediaWiki master
ParserFactory.php
Go to the documentation of this file.
1<?php
41use Psr\Log\LoggerInterface;
42
48 private $svcOptions;
49
51 private $magicWordFactory;
52
54 private $contLang;
55
57 private $urlUtils;
58
60 private $specialPageFactory;
61
63 private $linkRendererFactory;
64
66 private $nsInfo;
67
69 private $logger;
70
72 private $badFileLookup;
73
75 private $languageConverterFactory;
76
78 private $languageNameUtils;
79
81 private $userOptionsLookup;
82
84 private $userFactory;
85
87 private $titleFormatter;
88
90 private $httpRequestFactory;
91
93 private $trackingCategories;
94
96 private $signatureValidatorFactory;
97
99 private $userNameUtils;
100
109 public static $inParserFactory = 0;
110
112 private $hookContainer;
113
115 private $tidy;
116
118 private $wanCache;
119
121 private $mainInstance;
122
148 public function __construct(
149 ServiceOptions $svcOptions,
150 MagicWordFactory $magicWordFactory,
151 Language $contLang,
152 UrlUtils $urlUtils,
153 SpecialPageFactory $spFactory,
154 LinkRendererFactory $linkRendererFactory,
155 NamespaceInfo $nsInfo,
156 LoggerInterface $logger,
157 BadFileLookup $badFileLookup,
158 LanguageConverterFactory $languageConverterFactory,
159 LanguageNameUtils $languageNameUtils,
160 HookContainer $hookContainer,
161 TidyDriverBase $tidy,
162 WANObjectCache $wanCache,
163 UserOptionsLookup $userOptionsLookup,
164 UserFactory $userFactory,
165 TitleFormatter $titleFormatter,
166 HttpRequestFactory $httpRequestFactory,
167 TrackingCategories $trackingCategories,
168 SignatureValidatorFactory $signatureValidatorFactory,
169 UserNameUtils $userNameUtils
170 ) {
171 $svcOptions->assertRequiredOptions( Parser::CONSTRUCTOR_OPTIONS );
172
173 wfDebug( __CLASS__ . ": using default preprocessor" );
174
175 $this->svcOptions = $svcOptions;
176 $this->magicWordFactory = $magicWordFactory;
177 $this->contLang = $contLang;
178 $this->urlUtils = $urlUtils;
179 $this->specialPageFactory = $spFactory;
180 $this->linkRendererFactory = $linkRendererFactory;
181 $this->nsInfo = $nsInfo;
182 $this->logger = $logger;
183 $this->badFileLookup = $badFileLookup;
184 $this->languageConverterFactory = $languageConverterFactory;
185 $this->languageNameUtils = $languageNameUtils;
186 $this->hookContainer = $hookContainer;
187 $this->tidy = $tidy;
188 $this->wanCache = $wanCache;
189 $this->userOptionsLookup = $userOptionsLookup;
190 $this->userFactory = $userFactory;
191 $this->titleFormatter = $titleFormatter;
192 $this->httpRequestFactory = $httpRequestFactory;
193 $this->trackingCategories = $trackingCategories;
194 $this->signatureValidatorFactory = $signatureValidatorFactory;
195 $this->userNameUtils = $userNameUtils;
196 }
197
208 public function create(): Parser {
209 self::$inParserFactory++;
210 try {
211 return new Parser(
212 $this->svcOptions,
213 $this->magicWordFactory,
214 $this->contLang,
215 $this,
216 $this->urlUtils,
217 $this->specialPageFactory,
218 $this->linkRendererFactory,
219 $this->nsInfo,
220 $this->logger,
221 $this->badFileLookup,
222 $this->languageConverterFactory,
223 $this->languageNameUtils,
224 $this->hookContainer,
225 $this->tidy,
226 $this->wanCache,
227 $this->userOptionsLookup,
228 $this->userFactory,
229 $this->titleFormatter,
230 $this->httpRequestFactory,
231 $this->trackingCategories,
232 $this->signatureValidatorFactory,
233 $this->userNameUtils
234 );
235 } finally {
236 self::$inParserFactory--;
237 }
238 }
239
252 public function getMainInstance() {
253 if ( $this->mainInstance === null ) {
254 $this->mainInstance = $this->create();
255 }
256 return $this->mainInstance;
257 }
258
270 public function getInstance() {
271 $instance = $this->getMainInstance();
272 if ( $instance->isLocked() ) {
273 $instance = $this->create();
274 }
275 return $instance;
276 }
277
278}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Base class for language-specific code.
Definition Language.php:66
This class performs some operations related to tracking categories, such as adding a tracking categor...
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Factory creating MWHttpRequest objects.
An interface for creating language converters.
A service that provides utilities to do with language names and codes.
Factory to create LinkRender objects.
Store information about magic words, and create/cache MagicWord objects.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:155
Factory for handling the special page list and generating SpecialPage objects.
Base class for HTML cleanup utilities.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Provides access to user options.
Creates User objects.
UserNameUtils service.
A service to expand, parse, and otherwise manipulate URLs.
Definition UrlUtils.php:16
getInstance()
Get the main shared instance, or if it is locked, get a new instance.
static int $inParserFactory
Track calls to Parser constructor to aid in deprecation of direct Parser invocation.
__construct(ServiceOptions $svcOptions, MagicWordFactory $magicWordFactory, Language $contLang, UrlUtils $urlUtils, SpecialPageFactory $spFactory, LinkRendererFactory $linkRendererFactory, NamespaceInfo $nsInfo, LoggerInterface $logger, BadFileLookup $badFileLookup, LanguageConverterFactory $languageConverterFactory, LanguageNameUtils $languageNameUtils, HookContainer $hookContainer, TidyDriverBase $tidy, WANObjectCache $wanCache, UserOptionsLookup $userOptionsLookup, UserFactory $userFactory, TitleFormatter $titleFormatter, HttpRequestFactory $httpRequestFactory, TrackingCategories $trackingCategories, SignatureValidatorFactory $signatureValidatorFactory, UserNameUtils $userNameUtils)
getMainInstance()
Get the main shared instance.
create()
Creates a new parser.
Multi-datacenter aware caching interface.
A title formatter service for MediaWiki.