MediaWiki master
ParserFactory.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Parser;
23
42use Psr\Log\LoggerInterface;
44
50 private $svcOptions;
51
53 private $magicWordFactory;
54
56 private $contLang;
57
59 private $urlUtils;
60
62 private $specialPageFactory;
63
65 private $linkRendererFactory;
66
68 private $nsInfo;
69
71 private $logger;
72
74 private $badFileLookup;
75
77 private $languageConverterFactory;
78
80 private $languageNameUtils;
81
83 private $userOptionsLookup;
84
86 private $userFactory;
87
89 private $titleFormatter;
90
92 private $httpRequestFactory;
93
95 private $trackingCategories;
96
98 private $signatureValidatorFactory;
99
101 private $userNameUtils;
102
111 public static $inParserFactory = 0;
112
114 private $hookContainer;
115
117 private $tidy;
118
120 private $wanCache;
121
123 private $mainInstance;
124
150 public function __construct(
151 ServiceOptions $svcOptions,
152 MagicWordFactory $magicWordFactory,
153 Language $contLang,
154 UrlUtils $urlUtils,
155 SpecialPageFactory $spFactory,
156 LinkRendererFactory $linkRendererFactory,
157 NamespaceInfo $nsInfo,
158 LoggerInterface $logger,
159 BadFileLookup $badFileLookup,
160 LanguageConverterFactory $languageConverterFactory,
161 LanguageNameUtils $languageNameUtils,
162 HookContainer $hookContainer,
163 TidyDriverBase $tidy,
164 WANObjectCache $wanCache,
165 UserOptionsLookup $userOptionsLookup,
166 UserFactory $userFactory,
167 TitleFormatter $titleFormatter,
168 HttpRequestFactory $httpRequestFactory,
169 TrackingCategories $trackingCategories,
170 SignatureValidatorFactory $signatureValidatorFactory,
171 UserNameUtils $userNameUtils
172 ) {
174
175 wfDebug( __CLASS__ . ": using default preprocessor" );
176
177 $this->svcOptions = $svcOptions;
178 $this->magicWordFactory = $magicWordFactory;
179 $this->contLang = $contLang;
180 $this->urlUtils = $urlUtils;
181 $this->specialPageFactory = $spFactory;
182 $this->linkRendererFactory = $linkRendererFactory;
183 $this->nsInfo = $nsInfo;
184 $this->logger = $logger;
185 $this->badFileLookup = $badFileLookup;
186 $this->languageConverterFactory = $languageConverterFactory;
187 $this->languageNameUtils = $languageNameUtils;
188 $this->hookContainer = $hookContainer;
189 $this->tidy = $tidy;
190 $this->wanCache = $wanCache;
191 $this->userOptionsLookup = $userOptionsLookup;
192 $this->userFactory = $userFactory;
193 $this->titleFormatter = $titleFormatter;
194 $this->httpRequestFactory = $httpRequestFactory;
195 $this->trackingCategories = $trackingCategories;
196 $this->signatureValidatorFactory = $signatureValidatorFactory;
197 $this->userNameUtils = $userNameUtils;
198 }
199
210 public function create(): Parser {
211 self::$inParserFactory++;
212 try {
213 return new Parser(
214 $this->svcOptions,
215 $this->magicWordFactory,
216 $this->contLang,
217 $this,
218 $this->urlUtils,
219 $this->specialPageFactory,
220 $this->linkRendererFactory,
221 $this->nsInfo,
222 $this->logger,
223 $this->badFileLookup,
224 $this->languageConverterFactory,
225 $this->languageNameUtils,
226 $this->hookContainer,
227 $this->tidy,
228 $this->wanCache,
229 $this->userOptionsLookup,
230 $this->userFactory,
231 $this->titleFormatter,
232 $this->httpRequestFactory,
233 $this->trackingCategories,
234 $this->signatureValidatorFactory,
235 $this->userNameUtils
236 );
237 } finally {
238 self::$inParserFactory--;
239 }
240 }
241
254 public function getMainInstance() {
255 if ( $this->mainInstance === null ) {
256 $this->mainInstance = $this->create();
257 }
258 return $this->mainInstance;
259 }
260
272 public function getInstance() {
273 $instance = $this->getMainInstance();
274 if ( $instance->isLocked() ) {
275 $instance = $this->create();
276 }
277 return $instance;
278 }
279
280}
281
283class_alias( ParserFactory::class, 'ParserFactory' );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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.
Base class for language-specific code.
Definition Language.php:78
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.
__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)
static int $inParserFactory
Track calls to Parser constructor to aid in deprecation of direct Parser invocation.
getInstance()
Get the main shared instance, or if it is locked, get a new instance.
getMainInstance()
Get the main shared instance.
create()
Creates a new parser.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:143
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
Multi-datacenter aware caching interface.
A title formatter service for MediaWiki.