Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
CargoFormatParamsAPI | |
0.00% |
0 / 17 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
getAllowedParams | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getExamples | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Adds the 'cargoformatparams' action to the MediaWiki API. |
4 | * |
5 | * @ingroup Cargo |
6 | * |
7 | */ |
8 | class CargoFormatParamsAPI extends ApiBase { |
9 | |
10 | public function __construct( $query, $moduleName ) { |
11 | parent::__construct( $query, $moduleName ); |
12 | } |
13 | |
14 | public function execute() { |
15 | $params = $this->extractRequestParams(); |
16 | $queryFormat = $params['queryformat']; |
17 | $formatClasses = CargoQueryDisplayer::getAllFormatClasses(); |
18 | if ( !array_key_exists( $queryFormat, $formatClasses ) ) { |
19 | $this->dieWithError( "Format \"$queryFormat\" not found." ); |
20 | } |
21 | /** @var CargoDisplayFormat $formatClass */ |
22 | $formatClass = $formatClasses[$queryFormat]; |
23 | $data = $formatClass::allowedParameters(); |
24 | |
25 | // Set top-level elements. |
26 | $result = $this->getResult(); |
27 | $result->setIndexedTagName( $data, 'p' ); |
28 | $result->addValue( null, $this->getModuleName(), $data ); |
29 | } |
30 | |
31 | protected function getAllowedParams() { |
32 | return [ |
33 | 'queryformat' => null |
34 | ]; |
35 | } |
36 | |
37 | protected function getExamples() { |
38 | return [ |
39 | 'api.php?action=cargoformatparams&format=json&queryformat=calendar' |
40 | ]; |
41 | } |
42 | |
43 | } |