<?php
/**
- * ResourceLoader module for user tokens.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @author Krinkle
*/
/**
- * Module for user tokens
+ * Module for user authorization tokens.
+ *
+ * @ingroup ResourceLoader
+ * @internal
*/
class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
- /* Protected Members */
-
protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
protected $targets = [ 'desktop', 'mobile' ];
- /* Methods */
-
/**
* Fetch the tokens for the current user.
*
}
/**
- * Generate the JavaScript content of this module.
- *
- * Add FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
- *
* @param ResourceLoaderContext $context
- * @return string
+ * @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
- return Xml::encodeJsCall(
- 'mw.user.tokens.set',
- [ $this->contextUserTokens( $context ) ],
- ResourceLoader::inDebugMode()
- ) . ResourceLoader::FILTER_NOMIN;
+ // Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
+ return ResourceLoader::FILTER_NOMIN
+ . 'mw.user.tokens.set('
+ . ResourceLoader::encodeJsonForScript( $this->contextUserTokens( $context ) )
+ . ');';
}
/**
return false;
}
- /**
- * @return string
- */
- public function getPosition() {
- return 'top';
- }
-
/**
* @return string
*/