MediaWiki  master
ParserFactory.php
Go to the documentation of this file.
1 <?php
32 use Psr\Log\LoggerInterface;
33 
39  private $svcOptions;
40 
43 
45  private $contLang;
46 
48  private $urlProtocols;
49 
52 
55 
57  private $nsInfo;
58 
60  private $logger;
61 
63  private $badFileLookup;
64 
67 
70 
72  private $userFactory;
73 
75  private $titleFormatter;
76 
79 
88  public static $inParserFactory = 0;
89 
91  private $hookContainer;
92 
94  private $tidy;
95 
97  private $wanCache;
98 
120  public function __construct(
124  string $urlProtocols,
125  SpecialPageFactory $spFactory,
128  LoggerInterface $logger,
138  ) {
140 
141  wfDebug( __CLASS__ . ": using default preprocessor" );
142 
143  $this->svcOptions = $svcOptions;
144  $this->magicWordFactory = $magicWordFactory;
145  $this->contLang = $contLang;
146  $this->urlProtocols = $urlProtocols;
147  $this->specialPageFactory = $spFactory;
148  $this->linkRendererFactory = $linkRendererFactory;
149  $this->nsInfo = $nsInfo;
150  $this->logger = $logger;
151  $this->badFileLookup = $badFileLookup;
152  $this->languageConverterFactory = $languageConverterFactory;
153  $this->hookContainer = $hookContainer;
154  $this->tidy = $tidy;
155  $this->wanCache = $wanCache;
156  $this->userOptionsLookup = $userOptionsLookup;
157  $this->userFactory = $userFactory;
158  $this->titleFormatter = $titleFormatter;
159  $this->httpRequestFactory = $httpRequestFactory;
160  }
161 
168  public function create(): Parser {
169  self::$inParserFactory++;
170  try {
171  return new Parser(
172  $this->svcOptions,
173  $this->magicWordFactory,
174  $this->contLang,
175  $this,
176  $this->urlProtocols,
177  $this->specialPageFactory,
178  $this->linkRendererFactory,
179  $this->nsInfo,
180  $this->logger,
181  $this->badFileLookup,
182  $this->languageConverterFactory,
183  $this->hookContainer,
184  $this->tidy,
185  $this->wanCache,
186  $this->userOptionsLookup,
187  $this->userFactory,
188  $this->titleFormatter,
189  $this->httpRequestFactory
190  );
191  } finally {
192  self::$inParserFactory--;
193  }
194  }
195 }
ParserFactory\$contLang
Language $contLang
Definition: ParserFactory.php:45
ParserFactory\create
create()
Creates a new parser.
Definition: ParserFactory.php:168
ParserFactory\$magicWordFactory
MagicWordFactory $magicWordFactory
Definition: ParserFactory.php:42
MagicWordFactory
A factory that stores information about MagicWords, and creates them on demand with caching.
Definition: MagicWordFactory.php:37
MediaWiki\BadFileLookup
Definition: BadFileLookup.php:13
MediaWiki\Http\HttpRequestFactory
Factory creating MWHttpRequest objects.
Definition: HttpRequestFactory.php:39
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:63
ParserFactory\$hookContainer
HookContainer $hookContainer
Definition: ParserFactory.php:91
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:34
ParserFactory\$httpRequestFactory
HttpRequestFactory $httpRequestFactory
Definition: ParserFactory.php:78
ParserFactory\$badFileLookup
BadFileLookup $badFileLookup
Definition: ParserFactory.php:63
ParserFactory\$tidy
TidyDriverBase $tidy
Definition: ParserFactory.php:94
ParserFactory\$userFactory
UserFactory $userFactory
Definition: ParserFactory.php:72
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
ParserFactory\$logger
LoggerInterface $logger
Definition: ParserFactory.php:60
ParserFactory\$svcOptions
ServiceOptions $svcOptions
Definition: ParserFactory.php:39
ParserFactory\$urlProtocols
string $urlProtocols
Definition: ParserFactory.php:48
ParserFactory\__construct
__construct(ServiceOptions $svcOptions, MagicWordFactory $magicWordFactory, Language $contLang, string $urlProtocols, 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)
Definition: ParserFactory.php:120
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
ParserFactory\$userOptionsLookup
UserOptionsLookup $userOptionsLookup
Definition: ParserFactory.php:69
ParserFactory\$languageConverterFactory
LanguageConverterFactory $languageConverterFactory
Definition: ParserFactory.php:66
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:894
MediaWiki\Tidy\TidyDriverBase
Base class for HTML cleanup utilities.
Definition: TidyDriverBase.php:8
ParserFactory\$specialPageFactory
SpecialPageFactory $specialPageFactory
Definition: ParserFactory.php:51
ParserFactory
Definition: ParserFactory.php:37
Parser\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: Parser.php:372
ParserFactory\$inParserFactory
static int $inParserFactory
Track calls to Parser constructor to aid in deprecation of direct Parser invocation.
Definition: ParserFactory.php:88
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:128
ParserFactory\$titleFormatter
TitleFormatter $titleFormatter
Definition: ParserFactory.php:75
ParserFactory\$wanCache
WANObjectCache $wanCache
Definition: ParserFactory.php:97
Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:91
MediaWiki\User\UserOptionsLookup
Provides access to user options.
Definition: UserOptionsLookup.php:29
ParserFactory\$linkRendererFactory
LinkRendererFactory $linkRendererFactory
Definition: ParserFactory.php:54
ParserFactory\$nsInfo
NamespaceInfo $nsInfo
Definition: ParserFactory.php:57
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.php:35
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
MediaWiki\User\UserFactory
Creates User objects.
Definition: UserFactory.php:41
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42
MediaWiki\Config\ServiceOptions\assertRequiredOptions
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Definition: ServiceOptions.php:71