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

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. More...
 
static getRelativePaths (array $filePaths)
 Make file paths relative to MediaWiki directory. More...
 
- 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. More...
 
 getFileDependencies (ResourceLoaderContext $context)
 Get the files this module depends on indirectly for a given skin. More...
 
 getLogger ()
 
 getMessageBlob (ResourceLoaderContext $context)
 Get the hash of the message blob. More...
 
 saveFileDependencies (ResourceLoaderContext $context, $localFileRefs)
 Set the files this module depends on indirectly for a given skin. More...
 
 validateScriptFile ( $fileName, $contents)
 Validate a given script file; if valid returns the original source. More...
 
- Static Protected Member Functions inherited from ResourceLoaderModule
static javaScriptParser ()
 
static safeFileHash ( $filePath)
 Compute a non-cryptographic string hash of a file's contents. More...
 
static safeFilemtime ( $filePath)
 Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist. More...
 

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, $value, and as.

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 script(), and 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: