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

Public Member Functions

 __construct ( $options=[])
 
 enableModuleContentVersion ()
 Whether to generate version hash based on module content.
 
 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.
 
 getScript (ResourceLoaderContext $context)
 Get all JS for this module for a given language and skin.
 
 getSkipFunction ()
 Get the skip function.
 
 getSource ()
 Get the source 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 ()
 
 getDefinitionSummary (ResourceLoaderContext $context)
 Get the definition summary for this module.
 
 getDeprecationInformation ()
 Get JS representing deprecation information for the current module if available.
 
 getFlip ( $context)
 
 getHeaders (ResourceLoaderContext $context)
 Get headers to send as part of a module web response.
 
 getModuleContent (ResourceLoaderContext $context)
 Get an array of this module's resources.
 
 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.
 
 getVersionHash (ResourceLoaderContext $context)
 Get a string identifying the current version of this module in a given context.
 
 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 = []
 
 $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
 buildContent (ResourceLoaderContext $context)
 Bundle all resources attached to this module into an array.
 
 getFileDependencies (ResourceLoaderContext $context)
 Get the files this module depends on indirectly for a given skin.
 
 getLessVars (ResourceLoaderContext $context)
 Get module-specific LESS variables, if any.
 
 getLogger ()
 
 getMessageBlob (ResourceLoaderContext $context)
 Get the hash of the message blob.
 
 getPreloadLinks (ResourceLoaderContext $context)
 Get a list of resources that web browsers may preload.
 
 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 86 of file ResourceLoaderTestCase.php.

Constructor & Destructor Documentation

◆ __construct()

ResourceLoaderTestModule::__construct (   $options = [])

Definition at line 100 of file ResourceLoaderTestCase.php.

References $options, $value, and as.

Member Function Documentation

◆ enableModuleContentVersion()

ResourceLoaderTestModule::enableModuleContentVersion ( )

Whether to generate version hash based on module content.

If a module requires database or file system access to build the module content, consider disabling this in favour of manually tracking relevant aspects in getDefinitionSummary(). See getVersionHash() for how this is used.

Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 149 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 | null$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.

◆ 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 134 of file ResourceLoaderTestCase.php.

References $skipFunction.

◆ getSource()

ResourceLoaderTestModule::getSource ( )

Get the source of this module.

Should only be overridden for foreign modules.

Returns
string Source 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 130 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 141 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 138 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 145 of file ResourceLoaderTestCase.php.

References $context.

Member Data Documentation

◆ $dependencies

ResourceLoaderTestModule::$dependencies = []
protected

Definition at line 88 of file ResourceLoaderTestCase.php.

Referenced by getDependencies().

◆ $group

ResourceLoaderTestModule::$group = null
protected

Definition at line 89 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 87 of file ResourceLoaderTestCase.php.

Referenced by getMessages().

◆ $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 90 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: