MediaWiki REL1_37
ResourceLoaderUserDefaultsModule.php
Go to the documentation of this file.
1<?php
23
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}
MediaWikiServices is the service locator for the application scope of MediaWiki.
Context object that contains information about the state of a specific ResourceLoader web request.
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Abstraction for ResourceLoader modules, with name registration and maxage functionality.