28require_once __DIR__ .
'/../autoload.php';
62 $lowerClass = strtolower( $className );
64 if ( self::$autoloadLocalClassesLower ===
null ) {
68 if ( isset( self::$autoloadLocalClassesLower[$lowerClass] ) ) {
69 if ( function_exists(
'wfDebugLog' ) ) {
70 wfDebugLog(
'autoloader',
"Class {$className} was loaded using incorrect case" );
72 $filename = self::$autoloadLocalClassesLower[$lowerClass];
76 if ( !$filename && strpos( $className,
'\\' ) !==
false ) {
79 while (
false !== $pos = strrpos( $prefix,
'\\' ) ) {
81 $prefix = substr( $className, 0, $pos + 1 );
82 if ( isset( self::$psr4Namespaces[$prefix] ) ) {
83 $relativeClass = substr( $className, $pos + 1 );
85 $file = self::$psr4Namespaces[$prefix] .
'/' .
86 str_replace(
'\\',
'/', $relativeClass ) .
'.php';
87 if ( file_exists( $file ) ) {
94 $prefix = rtrim( $prefix,
'\\' );
104 if ( substr( $filename, 0, 1 ) !=
'/' && substr( $filename, 1, 1 ) !=
':' ) {
106 $filename =
"$IP/$filename";
117 self::$autoloadLocalClassesLower =
null;
132 'MediaWiki\\Auth\\' => __DIR__ .
'/auth/',
133 'MediaWiki\\Edit\\' => __DIR__ .
'/edit/',
134 'MediaWiki\\EditPage\\' => __DIR__ .
'/editpage/',
135 'MediaWiki\\Linker\\' => __DIR__ .
'/linker/',
136 'MediaWiki\\Preferences\\' => __DIR__ .
'/preferences/',
137 'MediaWiki\\Revision\\' => __DIR__ .
'/Revision/',
138 'MediaWiki\\Services\\' => __DIR__ .
'/services/',
139 'MediaWiki\\Session\\' => __DIR__ .
'/session/',
140 'MediaWiki\\Shell\\' => __DIR__ .
'/shell/',
141 'MediaWiki\\Sparql\\' => __DIR__ .
'/sparql/',
142 'MediaWiki\\Storage\\' => __DIR__ .
'/Storage/',
143 'MediaWiki\\Tidy\\' => __DIR__ .
'/tidy/',
149spl_autoload_register( [
'AutoLoader',
'autoload' ] );
$wgAutoloadAttemptLowercase
Switch controlling legacy case-insensitive classloading.
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
global $wgAutoloadLocalClasses
Locations of core classes Extension classes are specified with $wgAutoloadClasses This array is a glo...
static getAutoloadNamespaces()
Get a mapping of namespace => file path The namespaces should follow the PSR-4 standard for autoloadi...
static $autoloadLocalClassesLower
static string[] $psr4Namespaces
static autoload( $className)
autoload - take a class name and attempt to load it
static resetAutoloadLocalClassesLower()
Method to clear the protected class property $autoloadLocalClassesLower.
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