Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ApiFormatJsonVersion2 | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
getAllowedParams | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | namespace MediaWiki\Extension\EventStreamConfig; |
3 | |
4 | use MediaWiki\Api\ApiFormatJson; |
5 | use Wikimedia\ParamValidator\ParamValidator; |
6 | |
7 | /** |
8 | * Overrides ApiFormatJson::getAllowedParams to disable formatversion=1 |
9 | * and make formatversion=2 the default. |
10 | * This is needed to e.g. make sure output booleans are serialized properly, |
11 | * instead of as true => "" and false removed. |
12 | */ |
13 | class ApiFormatJsonVersion2 extends ApiFormatJson { |
14 | |
15 | /** |
16 | * @inheritDoc |
17 | */ |
18 | public function getAllowedParams() { |
19 | $allowedParams = parent::getAllowedParams(); |
20 | $allowedParams['formatversion'][ParamValidator::PARAM_TYPE] = [ '2', 'latest' ]; |
21 | $allowedParams['formatversion'][ParamValidator::PARAM_DEFAULT] = '2'; |
22 | return $allowedParams; |
23 | } |
24 | } |