MediaWiki  master
ParserFactory.php
Go to the documentation of this file.
1 <?php
26 
32  private $svcOptions;
33 
36 
38  private $contLang;
39 
41  private $urlProtocols;
42 
45 
48 
50  private $nsInfo;
51 
76  public function __construct(
79  $nsInfo = null
80  ) {
81  // @todo Do we need to retain compat for constructing this class directly?
82  if ( !$nsInfo ) {
83  wfDeprecated( __METHOD__ . ' with no NamespaceInfo argument', '1.34' );
84  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
85  }
86  if ( $linkRendererFactory instanceof Config ) {
87  // Old calling convention had an array in the format of $wgParserConf as the first
88  // parameter, and a Config as the sixth, with LinkRendererFactory as the seventh.
89  wfDeprecated( __METHOD__ . ' with Config parameter', '1.34' );
92  [ 'class' => Parser::class,
93  'preprocessorClass' => Parser::getDefaultPreprocessorClass() ],
94  func_get_arg( 5 )
95  );
96  $linkRendererFactory = func_get_arg( 6 );
97  $nsInfo = func_num_args() > 7 ? func_get_arg( 7 ) : null;
98  }
100 
101  wfDebug( __CLASS__ . ": using preprocessor: {$svcOptions->get( 'preprocessorClass' )}\n" );
102 
103  $this->svcOptions = $svcOptions;
104  $this->magicWordFactory = $magicWordFactory;
105  $this->contLang = $contLang;
106  $this->urlProtocols = $urlProtocols;
107  $this->specialPageFactory = $spFactory;
108  $this->linkRendererFactory = $linkRendererFactory;
109  $this->nsInfo = $nsInfo;
110  }
111 
116  public function create() : Parser {
117  return new Parser( $this->svcOptions, $this->magicWordFactory, $this->contLang, $this,
118  $this->urlProtocols, $this->specialPageFactory, $this->linkRendererFactory,
119  $this->nsInfo );
120  }
121 }
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
MagicWordFactory $magicWordFactory
ServiceOptions $svcOptions
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
A class for passing options to services.
Factory for handling the special page list and generating SpecialPage objects.
Interface for configuration instances.
Definition: Config.php:28
SpecialPageFactory $specialPageFactory
string $urlProtocols
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Language $contLang
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
LinkRendererFactory $linkRendererFactory
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys, without regard for order.
NamespaceInfo $nsInfo
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static array $constructorOptions
TODO Make this a const when HHVM support is dropped (T192166)
Definition: Parser.php:303
__construct( $svcOptions, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols, SpecialPageFactory $spFactory, $linkRendererFactory, $nsInfo=null)
Old parameter list, which we support for backwards compatibility, were: array $parserConf See $wgPars...
static getDefaultPreprocessorClass()
Which class should we use for the preprocessor if not otherwise specified?
Definition: Parser.php:429