MediaWiki REL1_34
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}
Context object that contains information about the state of a specific ResourceLoader web request.
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
Module for user authorization tokens.
contextUserTokens(ResourceLoaderContext $context)
Fetch the tokens for the current user.
getScript(ResourceLoaderContext $context)
$context
Definition load.php:45