MediaWiki  1.34.0
ExtensionRegistry Class Reference

ExtensionRegistry class. More...

Collaboration diagram for ExtensionRegistry:

Public Member Functions

 clearQueue ()
 Clear the current load queue. More...
 
 finish ()
 After this is called, no more extensions can be loaded. More...
 
 getAllThings ()
 Get information about all things. More...
 
 getAttribute ( $name)
 
 getQueue ()
 Get the current load queue. More...
 
 isLoaded ( $name, $constraint=' *')
 Whether a thing has been loaded. More...
 
 load ( $path)
 Loads and processes the given JSON file without delay. More...
 
 loadFromQueue ()
 
 queue ( $path)
 
 readFromQueue (array $queue)
 Process a queue of extensions and return their extracted data. More...
 
 setAttributeForTest ( $name, array $value)
 Force override the value of an attribute during tests. More...
 
 setCheckDevRequires ( $check)
 

Static Public Member Functions

static exportAutoloadClassesAndNamespaces ( $dir, $info, &$autoloadClasses=[], &$autoloadNamespaces=[])
 Export autoload classes and namespaces for a given directory and parsed JSON info file. More...
 
static getInstance ()
 

Public Attributes

const CACHE_VERSION = 7
 Bump whenever the registration cache needs resetting. More...
 
const MANIFEST_VERSION = 2
 Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when changing this. More...
 
const MANIFEST_VERSION_MW_VERSION = '>= 1.29.0'
 MediaWiki version constraint representing what the current highest MANIFEST_VERSION is supported in. More...
 
const MEDIAWIKI_CORE = 'MediaWiki'
 "requires" key that applies to MediaWiki core/$wgVersion More...
 
const MERGE_STRATEGY = '_merge_strategy'
 Special key that defines the merge strategy. More...
 
const OLDEST_MANIFEST_VERSION = 1
 Version of the oldest supported manifest version. More...
 

Protected Member Functions

 exportExtractedData (array $info)
 

Static Protected Member Functions

static processAutoLoader ( $dir, array $files)
 Fully expand autoloader paths. More...
 

Protected Attributes

array $attributes = []
 Items in the JSON file that aren't being set as globals. More...
 
bool $checkDev = false
 Whether to check dev-requires. More...
 
array $queued = []
 List of paths that should be loaded. More...
 
array $testAttributes = []
 Attributes for testing. More...
 

Private Member Functions

 buildVersionChecker ()
 Queries information about the software environment and constructs an appropiate version checker. More...
 
 getAbilities ()
 Get the list of abilities and their values. More...
 

Private Attributes

bool $finished = false
 Whether we are done loading things. More...
 
array $loaded = []
 Array of loaded things, keyed by name, values are credits information. More...
 

Static Private Attributes

static ExtensionRegistry $instance
 

Detailed Description

ExtensionRegistry class.

The Registry loads JSON files, and uses a Processor to extract information from them. It also registers classes with the autoloader.

Since
1.25

Definition at line 18 of file ExtensionRegistry.php.

Member Function Documentation

◆ buildVersionChecker()

ExtensionRegistry::buildVersionChecker ( )
private

Queries information about the software environment and constructs an appropiate version checker.

Returns
VersionChecker

Definition at line 242 of file ExtensionRegistry.php.

References $wgVersion, and getAbilities().

Referenced by readFromQueue().

◆ clearQueue()

ExtensionRegistry::clearQueue ( )

Clear the current load queue.

Not intended to be used outside of the installer.

Definition at line 214 of file ExtensionRegistry.php.

◆ exportAutoloadClassesAndNamespaces()

static ExtensionRegistry::exportAutoloadClassesAndNamespaces (   $dir,
  $info,
$autoloadClasses = [],
$autoloadNamespaces = [] 
)
static

Export autoload classes and namespaces for a given directory and parsed JSON info file.

Parameters
string$dir
array$info
array&$autoloadClasses
array&$autoloadNamespaces

Definition at line 353 of file ExtensionRegistry.php.

References $GLOBALS, AutoLoader\$psr4Namespaces, and processAutoLoader().

Referenced by readFromQueue().

◆ exportExtractedData()

ExtensionRegistry::exportExtractedData ( array  $info)
protected

Definition at line 367 of file ExtensionRegistry.php.

References $GLOBALS, $path, AutoLoader\$psr4Namespaces, MERGE_STRATEGY, and wfArrayPlus2d().

Referenced by loadFromQueue().

◆ finish()

ExtensionRegistry::finish ( )

After this is called, no more extensions can be loaded.

Since
1.29

Definition at line 223 of file ExtensionRegistry.php.

◆ getAbilities()

ExtensionRegistry::getAbilities ( )
private

Get the list of abilities and their values.

Returns
bool[]

Definition at line 231 of file ExtensionRegistry.php.

Referenced by buildVersionChecker(), and loadFromQueue().

◆ getAllThings()

ExtensionRegistry::getAllThings ( )

Get information about all things.

Returns
array

Definition at line 520 of file ExtensionRegistry.php.

References $loaded.

◆ getAttribute()

ExtensionRegistry::getAttribute (   $name)
Parameters
string$name
Returns
array

Definition at line 487 of file ExtensionRegistry.php.

◆ getInstance()

◆ getQueue()

ExtensionRegistry::getQueue ( )

Get the current load queue.

Not intended to be used outside of the installer.

Returns
array

Definition at line 206 of file ExtensionRegistry.php.

References $queued.

◆ isLoaded()

ExtensionRegistry::isLoaded (   $name,
  $constraint = '*' 
)

Whether a thing has been loaded.

Parameters
string$name
string$constraintThe required version constraint for this dependency
Exceptions
LogicExceptionif a specific contraint is asked for, but the extension isn't versioned
Returns
bool

Definition at line 468 of file ExtensionRegistry.php.

◆ load()

ExtensionRegistry::load (   $path)

Loads and processes the given JSON file without delay.

If some extensions are already queued, this will load those as well. TODO: Remove in MediaWiki 1.35

Deprecated:
since 1.34, use ExtensionRegistry->queue() instead
Parameters
string$pathAbsolute path to the JSON file

Definition at line 453 of file ExtensionRegistry.php.

References $path, loadFromQueue(), queue(), and wfDeprecated().

◆ loadFromQueue()

ExtensionRegistry::loadFromQueue ( )
Exceptions
MWExceptionIf the queue is already marked as finished (no further things should be loaded then).

Definition at line 147 of file ExtensionRegistry.php.

References $cache, $checkDev, $wgDevelopmentWarnings, $wgObjectCaches, $wgVersion, CACHE_VERSION, ObjectCache\detectLocalServerCache(), exportExtractedData(), getAbilities(), ObjectCache\newFromParams(), and readFromQueue().

Referenced by load().

◆ processAutoLoader()

static ExtensionRegistry::processAutoLoader (   $dir,
array  $files 
)
staticprotected

Fully expand autoloader paths.

Parameters
string$dir
array$files
Returns
array

Definition at line 531 of file ExtensionRegistry.php.

References $file.

Referenced by exportAutoloadClassesAndNamespaces().

◆ queue()

ExtensionRegistry::queue (   $path)
Parameters
string$pathAbsolute path to the JSON file

Definition at line 125 of file ExtensionRegistry.php.

References $path, and $wgExtensionInfoMTime.

Referenced by load().

◆ readFromQueue()

ExtensionRegistry::readFromQueue ( array  $queue)

Process a queue of extensions and return their extracted data.

Parameters
array$queuekeys are filenames, values are ignored
Returns
array extracted info
Exceptions
Exception
ExtensionDependencyError

Definition at line 267 of file ExtensionRegistry.php.

References $path, $queue, buildVersionChecker(), exportAutoloadClassesAndNamespaces(), and wfDeprecated().

Referenced by loadFromQueue().

◆ setAttributeForTest()

ExtensionRegistry::setAttributeForTest (   $name,
array  $value 
)

Force override the value of an attribute during tests.

Parameters
string$nameName of attribute to override
array$valueValue to set
Returns
ScopedCallback to reset
Since
1.33

Definition at line 500 of file ExtensionRegistry.php.

◆ setCheckDevRequires()

ExtensionRegistry::setCheckDevRequires (   $check)
Since
1.34
Parameters
bool$check

Definition at line 118 of file ExtensionRegistry.php.

Member Data Documentation

◆ $attributes

array ExtensionRegistry::$attributes = []
protected

Items in the JSON file that aren't being set as globals.

Definition at line 81 of file ExtensionRegistry.php.

◆ $checkDev

bool ExtensionRegistry::$checkDev = false
protected

Whether to check dev-requires.

Definition at line 95 of file ExtensionRegistry.php.

Referenced by loadFromQueue().

◆ $finished

bool ExtensionRegistry::$finished = false
private

Whether we are done loading things.

Definition at line 73 of file ExtensionRegistry.php.

◆ $instance

ExtensionRegistry ExtensionRegistry::$instance
staticprivate

Definition at line 100 of file ExtensionRegistry.php.

Referenced by getInstance().

◆ $loaded

array ExtensionRegistry::$loaded = []
private

Array of loaded things, keyed by name, values are credits information.

Definition at line 59 of file ExtensionRegistry.php.

Referenced by getAllThings().

◆ $queued

array ExtensionRegistry::$queued = []
protected

List of paths that should be loaded.

Definition at line 66 of file ExtensionRegistry.php.

Referenced by getQueue().

◆ $testAttributes

array ExtensionRegistry::$testAttributes = []
protected

Attributes for testing.

Definition at line 88 of file ExtensionRegistry.php.

◆ CACHE_VERSION

const ExtensionRegistry::CACHE_VERSION = 7

Bump whenever the registration cache needs resetting.

Definition at line 45 of file ExtensionRegistry.php.

Referenced by loadFromQueue().

◆ MANIFEST_VERSION

const ExtensionRegistry::MANIFEST_VERSION = 2

Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when changing this.

Definition at line 29 of file ExtensionRegistry.php.

Referenced by UpdateExtensionJsonSchema\execute(), ConvertExtensionToRegistration\execute(), and ExtensionJsonValidator\validate().

◆ MANIFEST_VERSION_MW_VERSION

const ExtensionRegistry::MANIFEST_VERSION_MW_VERSION = '>= 1.29.0'

MediaWiki version constraint representing what the current highest MANIFEST_VERSION is supported in.

Definition at line 35 of file ExtensionRegistry.php.

Referenced by ConvertExtensionToRegistration\execute().

◆ MEDIAWIKI_CORE

const ExtensionRegistry::MEDIAWIKI_CORE = 'MediaWiki'

"requires" key that applies to MediaWiki core/$wgVersion

Definition at line 23 of file ExtensionRegistry.php.

Referenced by VersionChecker\checkArray(), and ConvertExtensionToRegistration\execute().

◆ MERGE_STRATEGY

const ExtensionRegistry::MERGE_STRATEGY = '_merge_strategy'

Special key that defines the merge strategy.

Since
1.26

Definition at line 52 of file ExtensionRegistry.php.

Referenced by exportExtractedData(), ExtensionProcessor\extractConfig2(), ExtensionProcessor\getExtractedInfo(), and UpdateExtensionJsonSchema\updateTo2().

◆ OLDEST_MANIFEST_VERSION

const ExtensionRegistry::OLDEST_MANIFEST_VERSION = 1

Version of the oldest supported manifest version.

Definition at line 40 of file ExtensionRegistry.php.

Referenced by ExtensionJsonValidator\validate().


The documentation for this class was generated from the following file: