Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / api / ApiFormatPhp.php
blobccc6792e5ec0bfce12f63b1727d4ec6b1f33e0c0
1 <?php
2 /**
3 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
23 namespace MediaWiki\Api;
25 use Wikimedia\ParamValidator\ParamValidator;
27 /**
28 * API Serialized PHP output formatter
29 * @ingroup API
31 class ApiFormatPhp extends ApiFormatBase {
33 public function getMimeType() {
34 return 'application/vnd.php.serialized';
37 public function execute() {
38 $params = $this->extractRequestParams();
40 switch ( $params['formatversion'] ) {
41 case 1:
42 $transforms = [
43 'BC' => [],
44 'Types' => [],
45 'Strip' => 'all',
47 break;
49 case 2:
50 case 'latest':
51 $transforms = [
52 'Types' => [],
53 'Strip' => 'all',
55 break;
57 default:
58 // Should have been caught during parameter validation
59 self::dieDebug( __METHOD__, 'Unknown value for \'formatversion\'' );
61 $this->printText( serialize( $this->getResult()->getResultData( null, $transforms ) ) );
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',
80 /** @deprecated class alias since 1.43 */
81 class_alias( ApiFormatPhp::class, 'ApiFormatPhp' );