Debian Codegraph @

vendor/wikimedia/parsoid/extension/src/Rest/Handler/TransformHandler.php

raw
1 <?php
2 /**
3 * Copyright (C) 2011-2020 Wikimedia Foundation and others.
4 *
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.
9 *
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.
14 *
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 */
19 declare( strict_types = 1 );
20
21 namespace MWParsoid\Rest\Handler;
22
23 use MediaWiki\Rest\Handler\TransformHandler as CoreTransformHandler;
24 use Wikimedia\ParamValidator\ParamValidator;
25
26 /**
27 * Handler for transforming content given in the request.
28 * - /{domain}/v3/transform/{from}/to/{format}
29 * - /{domain}/v3/transform/{from}/to/{format}/{title}
30 * - /{domain}/v3/transform/{from}/to/{format}/{title}/{revision}
31 * @see https://www.mediawiki.org/wiki/Parsoid/API#POST
32 */
33 class TransformHandler extends CoreTransformHandler {
34
35 // NOTE: this controls redirects by overriding methods!
36 use EndpointRedirectTrait;
37
38 /** @inheritDoc */
39 public function getParamSettings() {
40 return [
41 // We need to verify that the correct domain is given, to avoid cache pollution.
42 'domain' => [
43 self::PARAM_SOURCE => 'path',
44 ParamValidator::PARAM_TYPE => 'string',
45 ParamValidator::PARAM_REQUIRED => true,
46 ]
47 ] + parent::getParamSettings();
48 }
49
50 }