Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
73.33% covered (warning)
73.33%
11 / 15
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ApiFlagConfig
73.33% covered (warning)
73.33%
11 / 15
50.00% covered (danger)
50.00%
1 / 2
3.17
0.00% covered (danger)
0.00%
0 / 1
 execute
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
 getExamplesMessages
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
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/**
25 * API module to get flag config info
26 *
27 * @ingroup FlaggedRevs
28 */
29class ApiFlagConfig extends ApiBase {
30
31    /**
32     * @inheritDoc
33     */
34    public function execute() {
35        $this->getMain()->setCacheMode( 'public' );
36        $data = [];
37        if ( !FlaggedRevs::useOnlyIfProtected() ) {
38            $data[] = [
39                'name'   => FlaggedRevs::getTagName(),
40                'levels' => FlaggedRevs::getMaxLevel(),
41                'tier1'  => 1,
42            ];
43        }
44        $result = $this->getResult();
45        $result->setIndexedTagName( $data, 'tag' );
46        $result->addValue( null, $this->getModuleName(), $data );
47    }
48
49    /**
50     * @inheritDoc
51     */
52    protected function getExamplesMessages() {
53        return [
54            'action=flagconfig'
55                => 'apihelp-flagconfig-example-1',
56        ];
57    }
58}