MediaWiki master
ParserFactory.php
Go to the documentation of this file.
1<?php
40use Psr\Log\LoggerInterface;
41
47 private $svcOptions;
48
50 private $magicWordFactory;
51
53 private $contLang;
54
56 private $urlUtils;
57
59 private $specialPageFactory;
60
62 private $linkRendererFactory;
63
65 private $nsInfo;
66
68 private $logger;
69
71 private $badFileLookup;
72
74 private $languageConverterFactory;
75
77 private $userOptionsLookup;
78
80 private $userFactory;
81
83 private $titleFormatter;
84
86 private $httpRequestFactory;
87
89 private $trackingCategories;
90
92 private $signatureValidatorFactory;
93
95 private $userNameUtils;
96
105 public static $inParserFactory = 0;
106
108 private $hookContainer;
109
111 private $tidy;
112
114 private $wanCache;
115
117 private $mainInstance;
118
143 public function __construct(
144 ServiceOptions $svcOptions,
145 MagicWordFactory $magicWordFactory,
146 Language $contLang,
147 UrlUtils $urlUtils,
148 SpecialPageFactory $spFactory,
149 LinkRendererFactory $linkRendererFactory,
150 NamespaceInfo $nsInfo,
151 LoggerInterface $logger,
152 BadFileLookup $badFileLookup,
153 LanguageConverterFactory $languageConverterFactory,
154 HookContainer $hookContainer,
155 TidyDriverBase $tidy,
156 WANObjectCache $wanCache,
157 UserOptionsLookup $userOptionsLookup,
158 UserFactory $userFactory,
159 TitleFormatter $titleFormatter,
160 HttpRequestFactory $httpRequestFactory,
161 TrackingCategories $trackingCategories,
162 SignatureValidatorFactory $signatureValidatorFactory,
163 UserNameUtils $userNameUtils
164 ) {
165 $svcOptions->assertRequiredOptions( Parser::CONSTRUCTOR_OPTIONS );
166
167 wfDebug( __CLASS__ . ": using default preprocessor" );
168
169 $this->svcOptions = $svcOptions;
170 $this->magicWordFactory = $magicWordFactory;
171 $this->contLang = $contLang;
172 $this->urlUtils = $urlUtils;
173 $this->specialPageFactory = $spFactory;
174 $this->linkRendererFactory = $linkRendererFactory;
175 $this->nsInfo = $nsInfo;
176 $this->logger = $logger;
177 $this->badFileLookup = $badFileLookup;
178 $this->languageConverterFactory = $languageConverterFactory;
179 $this->hookContainer = $hookContainer;
180 $this->tidy = $tidy;
181 $this->wanCache = $wanCache;
182 $this->userOptionsLookup = $userOptionsLookup;
183 $this->userFactory = $userFactory;
184 $this->titleFormatter = $titleFormatter;
185 $this->httpRequestFactory = $httpRequestFactory;
186 $this->trackingCategories = $trackingCategories;
187 $this->signatureValidatorFactory = $signatureValidatorFactory;
188 $this->userNameUtils = $userNameUtils;
189 }
190
201 public function create(): Parser {
202 self::$inParserFactory++;
203 try {
204 return new Parser(
205 $this->svcOptions,
206 $this->magicWordFactory,
207 $this->contLang,
208 $this,
209 $this->urlUtils,
210 $this->specialPageFactory,
211 $this->linkRendererFactory,
212 $this->nsInfo,
213 $this->logger,
214 $this->badFileLookup,
215 $this->languageConverterFactory,
216 $this->hookContainer,
217 $this->tidy,
218 $this->wanCache,
219 $this->userOptionsLookup,
220 $this->userFactory,
221 $this->titleFormatter,
222 $this->httpRequestFactory,
223 $this->trackingCategories,
224 $this->signatureValidatorFactory,
225 $this->userNameUtils
226 );
227 } finally {
228 self::$inParserFactory--;
229 }
230 }
231
244 public function getMainInstance() {
245 if ( $this->mainInstance === null ) {
246 $this->mainInstance = $this->create();
247 }
248 return $this->mainInstance;
249 }
250
262 public function getInstance() {
263 $instance = $this->getMainInstance();
264 if ( $instance->isLocked() ) {
265 $instance = $this->create();
266 }
267 return $instance;
268 }
269
270}
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:63
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.
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:156
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, 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.