MediaWiki
REL1_37
ResourceLoaderUserDefaultsModule.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\MediaWikiServices
;
23
30
class
ResourceLoaderUserDefaultsModule
extends
ResourceLoaderModule
{
31
protected
$targets
= [
'desktop'
,
'mobile'
];
32
36
public
function
enableModuleContentVersion
() {
37
return
true
;
38
}
39
44
public
function
getScript
(
ResourceLoaderContext
$context ) {
45
// TODO inject
46
$defaults = MediaWikiServices::getInstance()->getUserOptionsLookup()->getDefaultOptions();
47
48
return
'mw.user.options.set('
49
. $context->
encodeJson
( $defaults )
50
.
');'
;
51
}
52
}
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:190
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition
ResourceLoaderContext.php:34
ResourceLoaderContext\encodeJson
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Definition
ResourceLoaderContext.php:432
ResourceLoaderModule
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
Definition
ResourceLoaderModule.php:39
ResourceLoaderUserDefaultsModule
Module for default user preferences.
Definition
ResourceLoaderUserDefaultsModule.php:30
ResourceLoaderUserDefaultsModule\getScript
getScript(ResourceLoaderContext $context)
Definition
ResourceLoaderUserDefaultsModule.php:44
ResourceLoaderUserDefaultsModule\$targets
$targets
Definition
ResourceLoaderUserDefaultsModule.php:31
ResourceLoaderUserDefaultsModule\enableModuleContentVersion
enableModuleContentVersion()
Definition
ResourceLoaderUserDefaultsModule.php:36
includes
resourceloader
ResourceLoaderUserDefaultsModule.php
Generated on Fri Apr 5 2024 23:40:45 for MediaWiki by
1.9.8