MediaWiki  master
ResourceLoaderUserOptionsModule.php
Go to the documentation of this file.
1 <?php
30 
31  protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
32 
33  protected $targets = [ 'desktop', 'mobile' ];
34 
39  public function getDependencies( ResourceLoaderContext $context = null ) {
40  return [ 'user.defaults' ];
41  }
42 
46  public function enableModuleContentVersion() {
47  return true;
48  }
49 
55  // Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
56  return ResourceLoader::FILTER_NOMIN
57  . 'mw.user.options.set('
58  . $context->encodeJson(
59  $context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS )
60  )
61  . ');';
62  }
63 
67  public function supportsURLLoading() {
68  return false;
69  }
70 
76  return !$context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS );
77  }
78 
82  public function getGroup() {
83  return 'private';
84  }
85 }
$context
Definition: load.php:45
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
const GETOPTIONS_EXCLUDE_DEFAULTS
Exclude user options that are set to their default value.
Definition: User.php:73
isKnownEmpty(ResourceLoaderContext $context)
getScript(ResourceLoaderContext $context)
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode...
getDependencies(ResourceLoaderContext $context=null)
getUserObj()
Get the possibly-cached User object for the specified username.
Context object that contains information about the state of a specific ResourceLoader web request...