MediaWiki master
ApiFormatPhp.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Api;
24
26
32
33 public function getMimeType() {
34 return 'application/vnd.php.serialized';
35 }
36
37 public function execute() {
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 // Should have been caught during parameter validation
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',
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
81class_alias( ApiFormatPhp::class, 'ApiFormatPhp' );
array $params
The job parameters.
getResult()
Get the result object.
Definition ApiBase.php:710
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
Definition ApiBase.php:224
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition ApiBase.php:1808
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:184
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:851
This is the abstract base class for API formatters.
printText( $text)
Append text to the output buffer.
API Serialized PHP output formatter.
getMimeType()
Overriding class returns the MIME type that should be sent to the client.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Service for formatting and validating API parameters.