Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
73.33% |
11 / 15 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
ApiFlagConfig | |
73.33% |
11 / 15 |
|
50.00% |
1 / 2 |
3.17 | |
0.00% |
0 / 1 |
execute | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 | |||
getExamplesMessages | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Created on November 6, 2009 |
5 | * |
6 | * API module for MediaWiki's FlaggedRevs extension |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; if not, write to the Free Software Foundation, Inc., |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | * http://www.gnu.org/copyleft/gpl.html |
22 | */ |
23 | |
24 | use MediaWiki\Api\ApiBase; |
25 | |
26 | /** |
27 | * API module to get flag config info |
28 | * |
29 | * @ingroup FlaggedRevs |
30 | */ |
31 | class ApiFlagConfig extends ApiBase { |
32 | |
33 | /** |
34 | * @inheritDoc |
35 | */ |
36 | public function execute() { |
37 | $this->getMain()->setCacheMode( 'public' ); |
38 | $data = []; |
39 | if ( !FlaggedRevs::useOnlyIfProtected() ) { |
40 | $data[] = [ |
41 | 'name' => FlaggedRevs::getTagName(), |
42 | 'levels' => FlaggedRevs::getMaxLevel(), |
43 | 'tier1' => 1, |
44 | ]; |
45 | } |
46 | $result = $this->getResult(); |
47 | $result->setIndexedTagName( $data, 'tag' ); |
48 | $result->addValue( null, $this->getModuleName(), $data ); |
49 | } |
50 | |
51 | /** |
52 | * @inheritDoc |
53 | */ |
54 | protected function getExamplesMessages() { |
55 | return [ |
56 | 'action=flagconfig' |
57 | => 'apihelp-flagconfig-example-1', |
58 | ]; |
59 | } |
60 | } |