Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
SearchnamespaceTokenModule | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
getScript | |
100.00% |
6 / 6 |
|
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\Html\Html; |
6 | use MediaWiki\ResourceLoader as RL; |
7 | |
8 | /** |
9 | * ResourceLoader module providing the users "searchnamespace" token. |
10 | */ |
11 | class SearchnamespaceTokenModule extends RL\Module { |
12 | |
13 | /** @inheritDoc */ |
14 | protected $origin = self::ORIGIN_CORE_INDIVIDUAL; |
15 | |
16 | /** @inheritDoc */ |
17 | public function getScript( RL\Context $context ) { |
18 | $user = $context->getUserObj(); |
19 | return Html::encodeJsCall( |
20 | 'mw.user.tokens.set', |
21 | [ 'searchnamespaceToken', $user->getEditToken( 'searchnamespace' ) ], |
22 | (bool)$context->getDebug() |
23 | ); |
24 | } |
25 | |
26 | /** @inheritDoc */ |
27 | public function supportsURLLoading() { |
28 | return false; |
29 | } |
30 | |
31 | /** @inheritDoc */ |
32 | public function getGroup() { |
33 | // Private modules can not be loaded as a dependency, only via OutputPage::addModules(). |
34 | return 'private'; |
35 | } |
36 | |
37 | } |