Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
7 / 7 |
SearchnamespaceTokenModule | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
7 / 7 |
getScript | |
100.00% |
1 / 1 |
1 | |
100.00% |
5 / 5 |
|||
supportsURLLoading | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getGroup | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace AdvancedSearch; | |
use ResourceLoader; | |
use ResourceLoaderContext; | |
use ResourceLoaderModule; | |
use Xml; | |
/** | |
* ResourceLoader module providing the users "searchnamespace" token. | |
*/ | |
class SearchnamespaceTokenModule extends ResourceLoaderModule { | |
/** | |
* @var int | |
*/ | |
protected $origin = self::ORIGIN_CORE_INDIVIDUAL; | |
/** | |
* @var string[] | |
*/ | |
protected $targets = [ 'desktop', 'mobile' ]; | |
/** | |
* @param ResourceLoaderContext $context | |
* | |
* @return string JavaScript code | |
*/ | |
public function getScript( ResourceLoaderContext $context ) { | |
$user = $context->getUserObj(); | |
// Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960). | |
return ResourceLoader::FILTER_NOMIN . | |
Xml::encodeJsCall( | |
'mw.user.tokens.set', | |
[ 'searchnamespaceToken', $user->getEditToken( 'searchnamespace' ) ], | |
(bool)ResourceLoader::inDebugMode() | |
); | |
} | |
/** | |
* @return bool | |
*/ | |
public function supportsURLLoading() { | |
return false; | |
} | |
/** | |
* @return string | |
*/ | |
public function getGroup() { | |
// Private modules can not be loaded as a dependency, only via OutputPage::addModules(). | |
return 'private'; | |
} | |
} |