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 
82 
91  public static $inParserFactory = 0;
92 
94  private $hookContainer;
95 
97  private $tidy;
98 
100  private $wanCache;
101 
124  public function __construct(
128  string $urlProtocols,
129  SpecialPageFactory $spFactory,
132  LoggerInterface $logger,
143  ) {
145 
146  wfDebug( __CLASS__ . ": using default preprocessor" );
147 
148  $this->svcOptions = $svcOptions;
149  $this->magicWordFactory = $magicWordFactory;
150  $this->contLang = $contLang;
151  $this->urlProtocols = $urlProtocols;
152  $this->specialPageFactory = $spFactory;
153  $this->linkRendererFactory = $linkRendererFactory;
154  $this->nsInfo = $nsInfo;
155  $this->logger = $logger;
156  $this->badFileLookup = $badFileLookup;
157  $this->languageConverterFactory = $languageConverterFactory;
158  $this->hookContainer = $hookContainer;
159  $this->tidy = $tidy;
160  $this->wanCache = $wanCache;
161  $this->userOptionsLookup = $userOptionsLookup;
162  $this->userFactory = $userFactory;
163  $this->titleFormatter = $titleFormatter;
164  $this->httpRequestFactory = $httpRequestFactory;
165  $this->trackingCategories = $trackingCategories;
166  }
167 
174  public function create(): Parser {
175  self::$inParserFactory++;
176  try {
177  return new Parser(
178  $this->svcOptions,
179  $this->magicWordFactory,
180  $this->contLang,
181  $this,
182  $this->urlProtocols,
183  $this->specialPageFactory,
184  $this->linkRendererFactory,
185  $this->nsInfo,
186  $this->logger,
187  $this->badFileLookup,
188  $this->languageConverterFactory,
189  $this->hookContainer,
190  $this->tidy,
191  $this->wanCache,
192  $this->userOptionsLookup,
193  $this->userFactory,
194  $this->titleFormatter,
195  $this->httpRequestFactory,
196  $this->trackingCategories
197  );
198  } finally {
199  self::$inParserFactory--;
200  }
201  }
202 }
ParserFactory\$contLang
Language $contLang
Definition: ParserFactory.php:45
ParserFactory\create
create()
Creates a new parser.
Definition: ParserFactory.php:174
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:35
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:63
ParserFactory\$trackingCategories
TrackingCategories $trackingCategories
Definition: ParserFactory.php:81
ParserFactory\$hookContainer
HookContainer $hookContainer
Definition: ParserFactory.php:94
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:97
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
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:408
ParserFactory\$inParserFactory
static int $inParserFactory
Track calls to Parser constructor to aid in deprecation of direct Parser invocation.
Definition: ParserFactory.php:91
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:131
ParserFactory\$titleFormatter
TitleFormatter $titleFormatter
Definition: ParserFactory.php:75
ParserFactory\$wanCache
WANObjectCache $wanCache
Definition: ParserFactory.php:100
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
TrackingCategories
This class performs some operations related to tracking categories, such as creating a list of all su...
Definition: TrackingCategories.php:32
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
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, TrackingCategories $trackingCategories)
Definition: ParserFactory.php:124
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