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
23 namespace MediaWiki\Api
;
25 use Wikimedia\ParamValidator\ParamValidator
;
28 * API Serialized PHP output formatter
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'] ) {
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() +
[
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' );