MediaWiki  1.34.0
ResourceLoaderUserTokensModule.php
Go to the documentation of this file.
1 <?php
28 
29  protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
30 
31  protected $targets = [ 'desktop', 'mobile' ];
32 
40  $user = $context->getUserObj();
41 
42  return [
43  'editToken' => $user->getEditToken(),
44  'patrolToken' => $user->getEditToken( 'patrol' ),
45  'watchToken' => $user->getEditToken( 'watch' ),
46  'csrfToken' => $user->getEditToken(),
47  ];
48  }
49 
55  // Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
56  return ResourceLoader::FILTER_NOMIN
57  . 'mw.user.tokens.set('
58  . $context->encodeJson( $this->contextUserTokens( $context ) )
59  . ');';
60  }
61 
65  public function supportsURLLoading() {
66  return false;
67  }
68 
72  public function getGroup() {
73  return 'private';
74  }
75 }
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition: ResourceLoaderContext.php:33
ResourceLoaderUserTokensModule\getScript
getScript(ResourceLoaderContext $context)
Definition: ResourceLoaderUserTokensModule.php:54
ResourceLoaderUserTokensModule\getGroup
getGroup()
Definition: ResourceLoaderUserTokensModule.php:72
ResourceLoaderUserTokensModule\contextUserTokens
contextUserTokens(ResourceLoaderContext $context)
Fetch the tokens for the current user.
Definition: ResourceLoaderUserTokensModule.php:39
ResourceLoaderUserTokensModule
Module for user authorization tokens.
Definition: ResourceLoaderUserTokensModule.php:27
ResourceLoaderUserTokensModule\$origin
$origin
Definition: ResourceLoaderUserTokensModule.php:29
ResourceLoaderUserTokensModule\$targets
$targets
Definition: ResourceLoaderUserTokensModule.php:31
$context
$context
Definition: load.php:45
ResourceLoaderModule
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
Definition: ResourceLoaderModule.php:37
ResourceLoaderUserTokensModule\supportsURLLoading
supportsURLLoading()
Definition: ResourceLoaderUserTokensModule.php:65