| 1 |
<?php |
| 2 |
|
| 3 |
" |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Api; |
| 24 |
|
| 25 |
use Wikimedia\ParamValidator\ParamValidator; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
class ApiFormatPhp extends ApiFormatBase { |
| 32 |
|
| 33 |
public function getMimeType() { |
| 34 |
return 'application/vnd.php.serialized'; |
| 35 |
} |
| 36 |
|
| 37 |
public function execute() { |
| 38 |
$params = $this->extractRequestParams(); |
| 39 |
|
| 40 |
switch ( $params['formatversion'] ) { |
| 41 |
case 1: |
| 42 |
$transforms = [ |
| 43 |
'BC' => [], |
| 44 |
'Types' => [], |
| 45 |
'Strip' => 'all', |
| 46 |
]; |
| 47 |
break; |
| 48 |
|
| 49 |
case 2: |
| 50 |
case 'latest': |
| 51 |
$transforms = [ |
| 52 |
'Types' => [], |
| 53 |
'Strip' => 'all', |
| 54 |
]; |
| 55 |
break; |
| 56 |
|
| 57 |
default: |
| 58 |
|
| 59 |
self::dieDebug( __METHOD__, 'Unknown value for \'formatversion\'' ); |
| 60 |
} |
| 61 |
$this->printText( serialize( $this->getResult()->getResultData( null, $transforms ) ) ); |
| 62 |
} |
| 63 |
|
| 64 |
public function getAllowedParams() { |
| 65 |
return parent::getAllowedParams() + [ |
| 66 |
'formatversion' => [ |
| 67 |
ParamValidator::PARAM_TYPE => [ '1', '2', 'latest' ], |
| 68 |
ParamValidator::PARAM_DEFAULT => '1', |
| 69 |
ApiBase::PARAM_HELP_MSG => 'apihelp-php-param-formatversion', |
| 70 |
ApiBase::PARAM_HELP_MSG_PER_VALUE => [ |
| 71 |
'1' => 'apihelp-php-paramvalue-formatversion-1', |
| 72 |
'2' => 'apihelp-php-paramvalue-formatversion-2', |
| 73 |
'latest' => 'apihelp-php-paramvalue-formatversion-latest', |
| 74 |
], |
| 75 |
], |
| 76 |
]; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
class_alias( ApiFormatPhp::class, 'ApiFormatPhp' ); |