Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
SearchnamespaceTokenModule | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
getScript | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
supportsURLLoading | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getGroup | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace AdvancedSearch; |
4 | |
5 | use MediaWiki\ResourceLoader as RL; |
6 | use MediaWiki\ResourceLoader\ResourceLoader; |
7 | use Xml; |
8 | |
9 | /** |
10 | * ResourceLoader module providing the users "searchnamespace" token. |
11 | */ |
12 | class SearchnamespaceTokenModule extends RL\Module { |
13 | |
14 | /** |
15 | * @var int |
16 | */ |
17 | protected $origin = self::ORIGIN_CORE_INDIVIDUAL; |
18 | |
19 | /** |
20 | * @param RL\Context $context |
21 | * @return string JavaScript code |
22 | */ |
23 | public function getScript( RL\Context $context ) { |
24 | $user = $context->getUserObj(); |
25 | // Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960). |
26 | return ResourceLoader::FILTER_NOMIN . |
27 | Xml::encodeJsCall( |
28 | 'mw.user.tokens.set', |
29 | [ 'searchnamespaceToken', $user->getEditToken( 'searchnamespace' ) ], |
30 | (bool)$context->getDebug() |
31 | ); |
32 | } |
33 | |
34 | /** |
35 | * @return bool |
36 | */ |
37 | public function supportsURLLoading() { |
38 | return false; |
39 | } |
40 | |
41 | /** |
42 | * @return string |
43 | */ |
44 | public function getGroup() { |
45 | // Private modules can not be loaded as a dependency, only via OutputPage::addModules(). |
46 | return 'private'; |
47 | } |
48 | |
49 | } |