MediaWiki REL1_39
ParserFactory.php
Go to the documentation of this file.
1<?php
35use Psr\Log\LoggerInterface;
36
42 private $svcOptions;
43
45 private $magicWordFactory;
46
48 private $contLang;
49
51 private $urlUtils;
52
54 private $specialPageFactory;
55
57 private $linkRendererFactory;
58
60 private $nsInfo;
61
63 private $logger;
64
66 private $badFileLookup;
67
69 private $languageConverterFactory;
70
72 private $userOptionsLookup;
73
75 private $userFactory;
76
78 private $titleFormatter;
79
81 private $httpRequestFactory;
82
84 private $trackingCategories;
85
87 private $signatureValidatorFactory;
88
90 private $userNameUtils;
91
100 public static $inParserFactory = 0;
101
103 private $hookContainer;
104
106 private $tidy;
107
109 private $wanCache;
110
112 private $mainInstance;
113
138 public function __construct(
139 ServiceOptions $svcOptions,
140 MagicWordFactory $magicWordFactory,
141 Language $contLang,
142 UrlUtils $urlUtils,
143 SpecialPageFactory $spFactory,
144 LinkRendererFactory $linkRendererFactory,
145 NamespaceInfo $nsInfo,
146 LoggerInterface $logger,
147 BadFileLookup $badFileLookup,
148 LanguageConverterFactory $languageConverterFactory,
149 HookContainer $hookContainer,
150 TidyDriverBase $tidy,
151 WANObjectCache $wanCache,
152 UserOptionsLookup $userOptionsLookup,
153 UserFactory $userFactory,
154 TitleFormatter $titleFormatter,
155 HttpRequestFactory $httpRequestFactory,
156 TrackingCategories $trackingCategories,
157 SignatureValidatorFactory $signatureValidatorFactory,
158 UserNameUtils $userNameUtils
159 ) {
161
162 wfDebug( __CLASS__ . ": using default preprocessor" );
163
164 $this->svcOptions = $svcOptions;
165 $this->magicWordFactory = $magicWordFactory;
166 $this->contLang = $contLang;
167 $this->urlUtils = $urlUtils;
168 $this->specialPageFactory = $spFactory;
169 $this->linkRendererFactory = $linkRendererFactory;
170 $this->nsInfo = $nsInfo;
171 $this->logger = $logger;
172 $this->badFileLookup = $badFileLookup;
173 $this->languageConverterFactory = $languageConverterFactory;
174 $this->hookContainer = $hookContainer;
175 $this->tidy = $tidy;
176 $this->wanCache = $wanCache;
177 $this->userOptionsLookup = $userOptionsLookup;
178 $this->userFactory = $userFactory;
179 $this->titleFormatter = $titleFormatter;
180 $this->httpRequestFactory = $httpRequestFactory;
181 $this->trackingCategories = $trackingCategories;
182 $this->signatureValidatorFactory = $signatureValidatorFactory;
183 $this->userNameUtils = $userNameUtils;
184 }
185
192 public function create(): Parser {
193 self::$inParserFactory++;
194 try {
195 return new Parser(
196 $this->svcOptions,
197 $this->magicWordFactory,
198 $this->contLang,
199 $this,
200 $this->urlUtils,
201 $this->specialPageFactory,
202 $this->linkRendererFactory,
203 $this->nsInfo,
204 $this->logger,
205 $this->badFileLookup,
206 $this->languageConverterFactory,
207 $this->hookContainer,
208 $this->tidy,
209 $this->wanCache,
210 $this->userOptionsLookup,
211 $this->userFactory,
212 $this->titleFormatter,
213 $this->httpRequestFactory,
214 $this->trackingCategories,
215 $this->signatureValidatorFactory,
216 $this->userNameUtils
217 );
218 } finally {
219 self::$inParserFactory--;
220 }
221 }
222
231 public function getMainInstance() {
232 if ( $this->mainInstance === null ) {
233 $this->mainInstance = $this->create();
234 }
235 return $this->mainInstance;
236 }
237
244 public function getInstance() {
245 $instance = $this->getMainInstance();
246 if ( $instance->isLocked() ) {
247 $instance = $this->create();
248 }
249 return $instance;
250 }
251
252}
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:53
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 creating MWHttpRequest objects.
An interface for creating language converters.
Factory to create LinkRender objects.
Factory for handling the special page list and generating SpecialPage objects.
Base class for HTML cleanup utilities.
Creates User objects.
UserNameUtils service.
Provides access to user options.
A service to expand, parse, and otherwise manipulate URLs.
Definition UrlUtils.php:17
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:96
const CONSTRUCTOR_OPTIONS
Definition Parser.php:408
This class performs some operations related to tracking categories, such as creating a list of all su...
Multi-datacenter aware caching interface.
A title formatter service for MediaWiki.