MediaWiki REL1_30
ResourceLoaderTestModule Class Reference
Inheritance diagram for ResourceLoaderTestModule:
Collaboration diagram for ResourceLoaderTestModule:

Public Member Functions

 __construct ( $options=[])
 
 enableModuleContentVersion ()
 
 getDependencies (ResourceLoaderContext $context=null)
 Get a list of modules this module depends on.
 
 getGroup ()
 Get the group this module is in.
 
 getMessages ()
 Get the messages needed for this module.
 
 getPosition ()
 From where in the page HTML should this module be loaded?
 
 getScript (ResourceLoaderContext $context)
 Get all JS for this module for a given language and skin.
 
 getSkipFunction ()
 Get the skip function.
 
 getSource ()
 Get the origin of this module.
 
 getStyles (ResourceLoaderContext $context)
 Get all CSS for this module for a given skin.
 
 getType ()
 Get the module's load type.
 
 isKnownEmpty (ResourceLoaderContext $context)
 Check whether this module is known to be empty.
 
 isRaw ()
 Whether this module's JS expects to work without the client-side ResourceLoader module.
 
 shouldEmbedModule (ResourceLoaderContext $context)
 Check whether this module should be embeded rather than linked.
 
- Public Member Functions inherited from ResourceLoaderModule
 getConfig ()
 
 getDefinitionMtime (ResourceLoaderContext $context)
 Back-compat dummy for old subclass implementations of getModifiedTime().
 
 getDefinitionSummary (ResourceLoaderContext $context)
 Get a list of resources that web browsers may preload.
 
 getFlip ( $context)
 
 getHashMtime (ResourceLoaderContext $context)
 Back-compat dummy for old subclass implementations of getModifiedTime().
 
 getHeaders (ResourceLoaderContext $context)
 Get headers to send as part of a module web response.
 
 getModifiedHash (ResourceLoaderContext $context)
 Helper method for providing a version hash to getVersionHash().
 
 getModifiedTime (ResourceLoaderContext $context)
 Get this module's last modification timestamp for a given context.
 
 getName ()
 Get this module's name.
 
 getOrigin ()
 Get this module's origin.
 
 getScriptURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's JS in debug mode.
 
 getStyleURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's CSS in debug mode.
 
 getTargets ()
 Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
 
 getTemplates ()
 Takes named templates by the module and returns an array mapping.
 
 setConfig (Config $config)
 
 setFileDependencies (ResourceLoaderContext $context, $files)
 Set in-object cache for file dependencies.
 
 setLogger (LoggerInterface $logger)
 
 setMessageBlob ( $blob, $lang)
 Set in-object cache for message blobs.
 
 setName ( $name)
 Set this module's name.
 
 supportsURLLoading ()
 Whether this module supports URL loading.
 

Protected Attributes

 $dependencies = []
 
 $group = null
 
 $isKnownEmpty = false
 
 $isRaw = false
 
 $messages = []
 
 $position = 'bottom'
 
 $script = ''
 
 $shouldEmbed = null
 
 $skipFunction = null
 
 $source = 'local'
 
 $styles = ''
 
 $targets = [ 'phpunit' ]
 
 $type = ResourceLoaderModule::LOAD_GENERAL
 
- Protected Attributes inherited from ResourceLoaderModule
Config $config
 
 $contents = []
 
array bool $deprecated = false
 
 $fileDeps = []
 
LoggerInterface $logger
 
 $msgBlobs = []
 
 $name = null
 
 $origin = self::ORIGIN_CORE_SITEWIDE
 
 $targets = [ 'desktop' ]
 
 $versionHash = []
 

Additional Inherited Members

- Static Public Member Functions inherited from ResourceLoaderModule
static expandRelativePaths (array $filePaths)
 Expand directories relative to $IP.
 
static getRelativePaths (array $filePaths)
 Make file paths relative to MediaWiki directory.
 
- Public Attributes inherited from ResourceLoaderModule
const LOAD_GENERAL = 'general'
 
const LOAD_STYLES = 'styles'
 
const ORIGIN_ALL = 10
 
const ORIGIN_CORE_INDIVIDUAL = 2
 
const ORIGIN_CORE_SITEWIDE = 1
 
const ORIGIN_USER_INDIVIDUAL = 4
 
const ORIGIN_USER_SITEWIDE = 3
 
const TYPE_COMBINED = 'combined'
 
const TYPE_SCRIPTS = 'scripts'
 
const TYPE_STYLES = 'styles'
 
- Protected Member Functions inherited from ResourceLoaderModule
 getDeprecationInformation ()
 Get JS representing deprecation information for the current module if available.
 
 getFileDependencies (ResourceLoaderContext $context)
 Get the files this module depends on indirectly for a given skin.
 
 getLogger ()
 
 getMessageBlob (ResourceLoaderContext $context)
 Get the hash of the message blob.
 
 saveFileDependencies (ResourceLoaderContext $context, $localFileRefs)
 Set the files this module depends on indirectly for a given skin.
 
 validateScriptFile ( $fileName, $contents)
 Validate a given script file; if valid returns the original source.
 
- Static Protected Member Functions inherited from ResourceLoaderModule
static javaScriptParser ()
 
static safeFileHash ( $filePath)
 Compute a non-cryptographic string hash of a file's contents.
 
static safeFilemtime ( $filePath)
 Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist.
 

Detailed Description

Definition at line 85 of file ResourceLoaderTestCase.php.

Constructor & Destructor Documentation

◆ __construct()

ResourceLoaderTestModule::__construct ( $options = [])

Definition at line 100 of file ResourceLoaderTestCase.php.

References $options, and $value.

Member Function Documentation

◆ enableModuleContentVersion()

ResourceLoaderTestModule::enableModuleContentVersion ( )

Definition at line 152 of file ResourceLoaderTestCase.php.

◆ getDependencies()

ResourceLoaderTestModule::getDependencies ( ResourceLoaderContext $context = null)

Get a list of modules this module depends on.

Dependency information is taken into account when loading a module on the client side.

Note: It is expected that $context will be made non-optional in the near future.

Parameters
ResourceLoaderContext$context
Returns
array List of module names as strings

Reimplemented from ResourceLoaderModule.

Definition at line 118 of file ResourceLoaderTestCase.php.

References $dependencies.

◆ getGroup()

ResourceLoaderTestModule::getGroup ( )

Get the group this module is in.

Returns
string Group name

Reimplemented from ResourceLoaderModule.

Definition at line 122 of file ResourceLoaderTestCase.php.

References $group.

◆ getMessages()

ResourceLoaderTestModule::getMessages ( )

Get the messages needed for this module.

To get a JSON blob with messages, use MessageBlobStore::get()

Returns
array List of message keys. Keys may occur more than once

Reimplemented from ResourceLoaderModule.

Definition at line 114 of file ResourceLoaderTestCase.php.

References $messages.

◆ getPosition()

ResourceLoaderTestModule::getPosition ( )

From where in the page HTML should this module be loaded?

Deprecated
since 1.29 Obsolete. All modules load async from <head>.
Returns
string

Reimplemented from ResourceLoaderModule.

Definition at line 129 of file ResourceLoaderTestCase.php.

References $position.

◆ getScript()

ResourceLoaderTestModule::getScript ( ResourceLoaderContext $context)

Get all JS for this module for a given language and skin.

Includes all relevant JS except loader scripts.

Parameters
ResourceLoaderContext$context
Returns
string JavaScript code

Reimplemented from ResourceLoaderModule.

Definition at line 106 of file ResourceLoaderTestCase.php.

References ResourceLoaderModule\validateScriptFile().

◆ getSkipFunction()

ResourceLoaderTestModule::getSkipFunction ( )

Get the skip function.

Modules that provide fallback functionality can provide a "skip function". This function, if provided, will be passed along to the module registry on the client. When this module is loaded (either directly or as a dependency of another module), then this function is executed first. If the function returns true, the module will instantly be considered "ready" without requesting the associated module resources.

The value returned here must be valid javascript for execution in a private function. It must not contain the "function () {" and "}" wrapper though.

Returns
string|null A JavaScript function body returning a boolean value, or null

Reimplemented from ResourceLoaderModule.

Definition at line 137 of file ResourceLoaderTestCase.php.

References $skipFunction.

◆ getSource()

ResourceLoaderTestModule::getSource ( )

Get the origin of this module.

Should only be overridden for foreign modules.

Returns
string Origin name, 'local' for local modules

Reimplemented from ResourceLoaderModule.

Definition at line 126 of file ResourceLoaderTestCase.php.

References $source.

◆ getStyles()

ResourceLoaderTestModule::getStyles ( ResourceLoaderContext $context)

Get all CSS for this module for a given skin.

Parameters
ResourceLoaderContext$context
Returns
array List of CSS strings or array of CSS strings keyed by media type. like [ 'screen' => '.foo { width: 0 }' ]; or [ 'screen' => [ '.foo { width: 0 }' ] ];

Reimplemented from ResourceLoaderModule.

Definition at line 110 of file ResourceLoaderTestCase.php.

References $styles.

◆ getType()

ResourceLoaderTestModule::getType ( )

Get the module's load type.

Since
1.28
Returns
string ResourceLoaderModule LOAD_* constant

Reimplemented from ResourceLoaderModule.

Definition at line 133 of file ResourceLoaderTestCase.php.

References $type.

◆ isKnownEmpty()

ResourceLoaderTestModule::isKnownEmpty ( ResourceLoaderContext $context)

Check whether this module is known to be empty.

If a child class has an easy and cheap way to determine that this module is definitely going to be empty, it should override this method to return true in that case. Callers may optimize the request for this module away if this function returns true.

Parameters
ResourceLoaderContext$context
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 144 of file ResourceLoaderTestCase.php.

References $isKnownEmpty.

◆ isRaw()

ResourceLoaderTestModule::isRaw ( )

Whether this module's JS expects to work without the client-side ResourceLoader module.

Returning true from this function will prevent mw.loader.state() call from being appended to the bottom of the script.

Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 141 of file ResourceLoaderTestCase.php.

References $isRaw.

◆ shouldEmbedModule()

ResourceLoaderTestModule::shouldEmbedModule ( ResourceLoaderContext $context)

Check whether this module should be embeded rather than linked.

Modules returning true here will be embedded rather than loaded by ResourceLoaderClientHtml.

Since
1.30
Parameters
ResourceLoaderContext$context
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 148 of file ResourceLoaderTestCase.php.

References $context.

Member Data Documentation

◆ $dependencies

ResourceLoaderTestModule::$dependencies = []
protected

Definition at line 87 of file ResourceLoaderTestCase.php.

Referenced by getDependencies().

◆ $group

ResourceLoaderTestModule::$group = null
protected

Definition at line 88 of file ResourceLoaderTestCase.php.

Referenced by getGroup().

◆ $isKnownEmpty

ResourceLoaderTestModule::$isKnownEmpty = false
protected

Definition at line 95 of file ResourceLoaderTestCase.php.

Referenced by isKnownEmpty().

◆ $isRaw

ResourceLoaderTestModule::$isRaw = false
protected

Definition at line 94 of file ResourceLoaderTestCase.php.

Referenced by isRaw().

◆ $messages

ResourceLoaderTestModule::$messages = []
protected

Definition at line 86 of file ResourceLoaderTestCase.php.

Referenced by getMessages().

◆ $position

ResourceLoaderTestModule::$position = 'bottom'
protected

Definition at line 90 of file ResourceLoaderTestCase.php.

Referenced by getPosition().

◆ $script

ResourceLoaderTestModule::$script = ''
protected

Definition at line 91 of file ResourceLoaderTestCase.php.

◆ $shouldEmbed

ResourceLoaderTestModule::$shouldEmbed = null
protected

Definition at line 98 of file ResourceLoaderTestCase.php.

◆ $skipFunction

ResourceLoaderTestModule::$skipFunction = null
protected

Definition at line 93 of file ResourceLoaderTestCase.php.

Referenced by getSkipFunction().

◆ $source

ResourceLoaderTestModule::$source = 'local'
protected

Definition at line 89 of file ResourceLoaderTestCase.php.

Referenced by getSource().

◆ $styles

ResourceLoaderTestModule::$styles = ''
protected

Definition at line 92 of file ResourceLoaderTestCase.php.

Referenced by getStyles().

◆ $targets

ResourceLoaderTestModule::$targets = [ 'phpunit' ]
protected

Definition at line 97 of file ResourceLoaderTestCase.php.

◆ $type

ResourceLoaderTestModule::$type = ResourceLoaderModule::LOAD_GENERAL
protected

Definition at line 96 of file ResourceLoaderTestCase.php.

Referenced by getType().


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