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