MediaWiki  master
ParserFactory.php
Go to the documentation of this file.
1 <?php
28 use Psr\Log\LoggerInterface;
29 
35  private $svcOptions;
36 
39 
41  private $contLang;
42 
44  private $urlProtocols;
45 
48 
51 
53  private $nsInfo;
54 
56  private $logger;
57 
59  private $badFileLookup;
60 
63 
72  public static $inParserFactory = 0;
73 
75  private $hookContainer;
76 
91  public function __construct(
95  string $urlProtocols,
96  SpecialPageFactory $spFactory,
99  LoggerInterface $logger,
103  ) {
105 
106  wfDebug( __CLASS__ . ": using default preprocessor" );
107 
108  $this->svcOptions = $svcOptions;
109  $this->magicWordFactory = $magicWordFactory;
110  $this->contLang = $contLang;
111  $this->urlProtocols = $urlProtocols;
112  $this->specialPageFactory = $spFactory;
113  $this->linkRendererFactory = $linkRendererFactory;
114  $this->nsInfo = $nsInfo;
115  $this->logger = $logger;
116  $this->badFileLookup = $badFileLookup;
117  $this->languageConverterFactory = $languageConverterFactory;
118  $this->hookContainer = $hookContainer;
119  }
120 
127  public function create() : Parser {
128  self::$inParserFactory++;
129  try {
130  return new Parser(
131  $this->svcOptions,
132  $this->magicWordFactory,
133  $this->contLang,
134  $this,
135  $this->urlProtocols,
136  $this->specialPageFactory,
137  $this->linkRendererFactory,
138  $this->nsInfo,
139  $this->logger,
140  $this->badFileLookup,
141  $this->languageConverterFactory,
142  $this->hookContainer
143  );
144  } finally {
145  self::$inParserFactory--;
146  }
147  }
148 }
ParserFactory\$contLang
Language $contLang
Definition: ParserFactory.php:41
ParserFactory\create
create()
Creates a new parser.
Definition: ParserFactory.php:127
ParserFactory\$magicWordFactory
MagicWordFactory $magicWordFactory
Definition: ParserFactory.php:38
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\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:61
ParserFactory\$hookContainer
HookContainer $hookContainer
Definition: ParserFactory.php:75
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:34
ParserFactory\$badFileLookup
BadFileLookup $badFileLookup
Definition: ParserFactory.php:59
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:44
ParserFactory\$logger
LoggerInterface $logger
Definition: ParserFactory.php:56
ParserFactory\$svcOptions
ServiceOptions $svcOptions
Definition: ParserFactory.php:35
ParserFactory\$urlProtocols
string $urlProtocols
Definition: ParserFactory.php:44
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
ParserFactory\$languageConverterFactory
LanguageConverterFactory $languageConverterFactory
Definition: ParserFactory.php:62
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:910
ParserFactory\$specialPageFactory
SpecialPageFactory $specialPageFactory
Definition: ParserFactory.php:47
ParserFactory
Definition: ParserFactory.php:33
Parser\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: Parser.php:364
ParserFactory\$inParserFactory
static int $inParserFactory
Track calls to Parser constructor to aid in deprecation of direct Parser invocation.
Definition: ParserFactory.php:72
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)
Definition: ParserFactory.php:91
Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:84
ParserFactory\$linkRendererFactory
LinkRendererFactory $linkRendererFactory
Definition: ParserFactory.php:50
ParserFactory\$nsInfo
NamespaceInfo $nsInfo
Definition: ParserFactory.php:53
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
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:66