MediaWiki REL1_40
ApiFormatPhp.php
Go to the documentation of this file.
1<?php
24
30
31 public function getMimeType() {
32 return 'application/vnd.php.serialized';
33 }
34
35 public function execute() {
36 $params = $this->extractRequestParams();
37
38 switch ( $params['formatversion'] ) {
39 case 1:
40 $transforms = [
41 'BC' => [],
42 'Types' => [],
43 'Strip' => 'all',
44 ];
45 break;
46
47 case 2:
48 case 'latest':
49 $transforms = [
50 'Types' => [],
51 'Strip' => 'all',
52 ];
53 break;
54
55 default:
56 // Should have been caught during parameter validation
57 self::dieDebug( __METHOD__, 'Unknown value for \'formatversion\'' );
58 }
59 $this->printText( serialize( $this->getResult()->getResultData( null, $transforms ) ) );
60 }
61
62 public function getAllowedParams() {
63 return parent::getAllowedParams() + [
64 'formatversion' => [
65 ParamValidator::PARAM_TYPE => [ '1', '2', 'latest' ],
66 ParamValidator::PARAM_DEFAULT => '1',
67 ApiBase::PARAM_HELP_MSG => 'apihelp-php-param-formatversion',
69 ],
70 ];
71 }
72}
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition ApiBase.php:1701
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
Definition ApiBase.php:204
getResult()
Get the result object.
Definition ApiBase.php:637
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:773
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:166
This is the abstract base class for API formatters.
printText( $text)
Append text to the output buffer.
API Serialized PHP output formatter.
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...
getMimeType()
Overriding class returns the MIME type that should be sent to the client.
Service for formatting and validating API parameters.