MediaWiki  master
ExtensionProcessor Class Reference

Utility class for loading extension manifests and aggregating their contents. More...

Inheritance diagram for ExtensionProcessor:
Collaboration diagram for ExtensionProcessor:

Public Member Functions

 extractInfo ( $path, array $info, $version)
 
 extractInfoFromFile (string $path)
 Extracts extension info from the given JSON file. More...
 
 getExtraAutoloaderPaths ( $dir, array $info)
 
 getExtractedAutoloadInfo (bool $includeDev=false)
 Returns the extracted autoload info. More...
 
 getExtractedInfo (bool $includeDev=false)
 
 getRequirements (array $info, $includeDev)
 Get the requirements for the provided info. More...
 
- Public Member Functions inherited from Processor
 getExtractedInfo ()
 

Protected Member Functions

 extractAttributes ( $path, array $info)
 
 extractConfig1 (array $info)
 Set configuration settings for manifest_version == 1. More...
 
 extractConfig2 (array $info, $dir)
 Set configuration settings for manifest_version == 2. More...
 
 extractCredits ( $path, array $info)
 
 extractExtensionMessagesFiles ( $dir, array $info)
 
 extractHooks (array $info, string $path)
 Extract hook information from Hooks and HookHandler attributes. More...
 
 extractMessagesDirs ( $dir, array $info)
 Set message-related settings, which need to be expanded to use absolute paths. More...
 
 extractNamespaces (array $info)
 Register namespaces with the appropriate global settings. More...
 
 extractPathBasedGlobal ( $global, $dir, $paths)
 
 extractResourceLoaderModules ( $dir, array $info)
 
 extractSkinImportPaths ( $dir, array $info)
 
 extractSkins ( $dir, array $info)
 Extract skins and handle path correction for templateDirectory. More...
 
 storeToArray ( $path, $name, $value, &$array)
 Stores $value to $array; using array_merge() if $array already contains $name. More...
 
 storeToArrayRecursive ( $path, $name, $value, &$array)
 Stores $value to $array; using array_merge_recursive() if $array already contains $name. More...
 

Protected Attributes

array $attributes = []
 Any thing else in the $info that hasn't already been processed. More...
 
string[][] $autoload
 Autoloader information. More...
 
string[][] $autoloadDev
 Autoloader information for development. More...
 
callable[] $callbacks = []
 Things to be called once registration of these extensions are done keyed by the name of the extension that it belongs to. More...
 
array $credits = []
 
array $defines = []
 Things that should be define()'d. More...
 
array $extAttributes = []
 Extension attributes, keyed by name => settings. More...
 
array $globals
 Stuff that is going to be set to $GLOBALS. More...
 

Static Protected Attributes

static array $globalSettings
 Keys that should be set to $GLOBALS. More...
 

Detailed Description

Utility class for loading extension manifests and aggregating their contents.

Stability: newable
since 1.39

Definition at line 12 of file ExtensionProcessor.php.

Member Function Documentation

◆ extractAttributes()

ExtensionProcessor::extractAttributes (   $path,
array  $info 
)
protected
Parameters
string$path
array$info

Definition at line 337 of file ExtensionProcessor.php.

References $path, and storeToArrayRecursive().

Referenced by extractInfo().

◆ extractConfig1()

ExtensionProcessor::extractConfig1 ( array  $info)
protected

Set configuration settings for manifest_version == 1.

Todo:
In the future, this should be done via Config interfaces
Parameters
array$info

Definition at line 778 of file ExtensionProcessor.php.

Referenced by extractInfo().

◆ extractConfig2()

ExtensionProcessor::extractConfig2 ( array  $info,
  $dir 
)
protected

Set configuration settings for manifest_version == 2.

Todo:
In the future, this should be done via Config interfaces
Parameters
array$info
string$dir

Definition at line 818 of file ExtensionProcessor.php.

References ExtensionRegistry\MERGE_STRATEGY.

Referenced by extractInfo().

◆ extractCredits()

ExtensionProcessor::extractCredits (   $path,
array  $info 
)
protected
Parameters
string$path
array$info
Returns
string Name of thing
Exceptions
Exception

Definition at line 746 of file ExtensionProcessor.php.

References $credits, and $path.

Referenced by extractInfo().

◆ extractExtensionMessagesFiles()

ExtensionProcessor::extractExtensionMessagesFiles (   $dir,
array  $info 
)
protected

Definition at line 667 of file ExtensionProcessor.php.

References $file.

Referenced by extractInfo().

◆ extractHooks()

ExtensionProcessor::extractHooks ( array  $info,
string  $path 
)
protected

Extract hook information from Hooks and HookHandler attributes.

Store hook in $wgHooks if a legacy style handler or the 'Hooks' attribute if a non-legacy handler

Parameters
array$infoattributes and associated values from extension.json
string$pathpath to extension.json

Definition at line 532 of file ExtensionProcessor.php.

References $path.

Referenced by extractInfo().

◆ extractInfo()

ExtensionProcessor::extractInfo (   $path,
array  $info,
  $version 
)

◆ extractInfoFromFile()

ExtensionProcessor::extractInfoFromFile ( string  $path)

Extracts extension info from the given JSON file.

Parameters
string$path
Returns
void

Definition at line 231 of file ExtensionProcessor.php.

References $path, extractInfo(), and wfDeprecatedMsg().

◆ extractMessagesDirs()

ExtensionProcessor::extractMessagesDirs (   $dir,
array  $info 
)
protected

Set message-related settings, which need to be expanded to use absolute paths.

Parameters
string$dir
array$info

Definition at line 683 of file ExtensionProcessor.php.

References $file.

Referenced by extractInfo().

◆ extractNamespaces()

ExtensionProcessor::extractNamespaces ( array  $info)
protected

Register namespaces with the appropriate global settings.

Parameters
array$info

Definition at line 566 of file ExtensionProcessor.php.

Referenced by extractInfo().

◆ extractPathBasedGlobal()

ExtensionProcessor::extractPathBasedGlobal (   $global,
  $dir,
  $paths 
)
protected

Definition at line 862 of file ExtensionProcessor.php.

References $path.

Referenced by extractInfo().

◆ extractResourceLoaderModules()

ExtensionProcessor::extractResourceLoaderModules (   $dir,
array  $info 
)
protected

Definition at line 610 of file ExtensionProcessor.php.

Referenced by extractInfo().

◆ extractSkinImportPaths()

ExtensionProcessor::extractSkinImportPaths (   $dir,
array  $info 
)
protected
Parameters
string$dir
array$info

Definition at line 732 of file ExtensionProcessor.php.

Referenced by extractInfo().

◆ extractSkins()

ExtensionProcessor::extractSkins (   $dir,
array  $info 
)
protected

Extract skins and handle path correction for templateDirectory.

Parameters
string$dir
array$info

Definition at line 699 of file ExtensionProcessor.php.

References wfDeprecatedMsg().

Referenced by extractInfo().

◆ getExtraAutoloaderPaths()

ExtensionProcessor::getExtraAutoloaderPaths (   $dir,
array  $info 
)
Deprecated:
since 1.39, use getExtractedAutoloadInfo instead
Parameters
string$dir
array$info
Returns
array

Implements Processor.

Definition at line 916 of file ExtensionProcessor.php.

References wfDeprecated().

◆ getExtractedAutoloadInfo()

ExtensionProcessor::getExtractedAutoloadInfo ( bool  $includeDev = false)

Returns the extracted autoload info.

The autoload info is returned as an associative array with three keys:

  • files: a list of files to load, for use with Autoloader::loadFile()
  • classes: a map of class names to files, for use with Autoloader::registerClass()
  • namespaces: a map of namespace names to directories, for use with Autoloader::registerNamespace()
Since
1.39
Parameters
bool$includeDev
Returns
array[] The autoload info.

Implements Processor.

Definition at line 939 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ getExtractedInfo()

ExtensionProcessor::getExtractedInfo ( bool  $includeDev = false)

◆ getRequirements()

ExtensionProcessor::getRequirements ( array  $info,
  $includeDev 
)

Get the requirements for the provided info.

Since
1.26
Parameters
array$info
bool$includeDev
Returns
array Where keys are the name to have a constraint on, like 'MediaWiki'. Values are a constraint string like "1.26.1".

Implements Processor.

Definition at line 383 of file ExtensionProcessor.php.

◆ storeToArray()

ExtensionProcessor::storeToArray (   $path,
  $name,
  $value,
$array 
)
protected

Stores $value to $array; using array_merge() if $array already contains $name.

Parameters
string$path
string$name
array$value
array&$array
Exceptions
InvalidArgumentException

Definition at line 897 of file ExtensionProcessor.php.

Referenced by extractInfo().

◆ storeToArrayRecursive()

ExtensionProcessor::storeToArrayRecursive (   $path,
  $name,
  $value,
$array 
)
protected

Stores $value to $array; using array_merge_recursive() if $array already contains $name.

Parameters
string$path
string$name
array$value
array&$array
Exceptions
InvalidArgumentException

Definition at line 877 of file ExtensionProcessor.php.

Referenced by extractAttributes(), extractInfo(), and getExtractedInfo().

Member Data Documentation

◆ $attributes

array ExtensionProcessor::$attributes = []
protected

Any thing else in the $info that hasn't already been processed.

Definition at line 214 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ $autoload

string [][] ExtensionProcessor::$autoload
protected
Initial value:
= [
'files' => [],
'classes' => [],
'namespaces' => [],
]

Autoloader information.

Each element is an array of strings. 'files' is just a list, 'classes' and 'namespaces' are associative.

Definition at line 190 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ $autoloadDev

string [][] ExtensionProcessor::$autoloadDev
protected
Initial value:
= [
'files' => [],
'classes' => [],
'namespaces' => [],
]

Autoloader information for development.

Same structure as $autoload.

Definition at line 202 of file ExtensionProcessor.php.

◆ $callbacks

callable [] ExtensionProcessor::$callbacks = []
protected

Things to be called once registration of these extensions are done keyed by the name of the extension that it belongs to.

Definition at line 176 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ $credits

array ExtensionProcessor::$credits = []
protected

Definition at line 181 of file ExtensionProcessor.php.

Referenced by extractCredits(), and getExtractedInfo().

◆ $defines

array ExtensionProcessor::$defines = []
protected

Things that should be define()'d.

Definition at line 168 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ $extAttributes

array ExtensionProcessor::$extAttributes = []
protected

Extension attributes, keyed by name => settings.

Definition at line 222 of file ExtensionProcessor.php.

◆ $globals

array ExtensionProcessor::$globals
protected
Initial value:
= [
'wgExtensionMessagesFiles' => [],
'wgMessagesDirs' => [],
]

Stuff that is going to be set to $GLOBALS.

Some keys are pre-set to arrays so we can += to them

Definition at line 158 of file ExtensionProcessor.php.

Referenced by getExtractedInfo().

◆ $globalSettings

array ExtensionProcessor::$globalSettings
staticprotected

Keys that should be set to $GLOBALS.

Definition at line 19 of file ExtensionProcessor.php.


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