MediaWiki
REL1_34
ResourceLoaderUserTokensModule.php
Go to the documentation of this file.
1
<?php
27
class
ResourceLoaderUserTokensModule
extends
ResourceLoaderModule
{
28
29
protected
$origin
= self::ORIGIN_CORE_INDIVIDUAL;
30
31
protected
$targets
= [
'desktop'
,
'mobile'
];
32
39
protected
function
contextUserTokens
(
ResourceLoaderContext
$context
) {
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
54
public
function
getScript
(
ResourceLoaderContext
$context
) {
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
ResourceLoaderModule
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
Definition
ResourceLoaderModule.php:37
ResourceLoaderUserTokensModule
Module for user authorization tokens.
Definition
ResourceLoaderUserTokensModule.php:27
ResourceLoaderUserTokensModule\getGroup
getGroup()
Definition
ResourceLoaderUserTokensModule.php:72
ResourceLoaderUserTokensModule\contextUserTokens
contextUserTokens(ResourceLoaderContext $context)
Fetch the tokens for the current user.
Definition
ResourceLoaderUserTokensModule.php:39
ResourceLoaderUserTokensModule\$targets
$targets
Definition
ResourceLoaderUserTokensModule.php:31
ResourceLoaderUserTokensModule\getScript
getScript(ResourceLoaderContext $context)
Definition
ResourceLoaderUserTokensModule.php:54
ResourceLoaderUserTokensModule\supportsURLLoading
supportsURLLoading()
Definition
ResourceLoaderUserTokensModule.php:65
ResourceLoaderUserTokensModule\$origin
$origin
Definition
ResourceLoaderUserTokensModule.php:29
$context
$context
Definition
load.php:45
includes
resourceloader
ResourceLoaderUserTokensModule.php
Generated on Mon Nov 25 2024 16:05:38 for MediaWiki by
1.10.0