39 'from' => [ self::PARAM_SOURCE =>
'path',
40 ParamValidator::PARAM_TYPE =>
'string',
41 ParamValidator::PARAM_REQUIRED =>
true, ],
42 'format' => [ self::PARAM_SOURCE =>
'path',
43 ParamValidator::PARAM_TYPE =>
'string',
44 ParamValidator::PARAM_REQUIRED =>
true, ],
45 'title' => [ self::PARAM_SOURCE =>
'path',
46 ParamValidator::PARAM_TYPE =>
'string',
47 ParamValidator::PARAM_REQUIRED =>
false, ],
48 'revision' => [ self::PARAM_SOURCE =>
'path',
49 ParamValidator::PARAM_TYPE =>
'string',
50 ParamValidator::PARAM_REQUIRED =>
false, ], ];
61 $from = $request->getPathParam(
'from' );
62 $format = $request->getPathParam(
'format' );
69 if ( !isset( $validTransformations[$from] ) || !in_array( $format,
70 $validTransformations[$from],
72 throw new HttpException(
"Invalid transform: {$from}/to/{$format}",
82 $wikitext = $attribs[
'opts'][
'wikitext'] ??
null;
83 if ( is_array( $wikitext ) ) {
84 $wikitext = $wikitext[
'body'];
86 if ( isset( $attribs[
'opts'][
'wikitext'][
'headers'][
'content-language'] ) ) {
87 $attribs[
'pagelanguage'] = $attribs[
'opts'][
'wikitext'][
'headers'][
'content-language'];
91 if ( $wikitext ===
null && isset( $attribs[
'opts'][
'original'][
'wikitext'] ) ) {
92 $wikitext = $attribs[
'opts'][
'original'][
'wikitext'][
'body'];
94 if ( isset( $attribs[
'opts'][
'original'][
'wikitext'][
'headers'][
'content-language'] ) ) {
95 $attribs[
'pagelanguage'] = $attribs[
'opts'][
'original'][
'wikitext'][
'headers'][
'content-language'];
99 if ( $wikitext ===
null && $attribs[
'titleMissing'] ) {
100 throw new HttpException(
'No title or wikitext was provided.',
106 return $this->
wt2html( $pageConfig,
110 $html = $attribs[
'opts'][
'html'] ??
null;
112 if ( is_array( $html ) ) {
113 $html = $html[
'body'];
115 if ( $html ===
null ) {
116 throw new HttpException(
'No html was supplied.',
119 $wikitext = $attribs[
'opts'][
'original'][
'wikitext'][
'body'] ??
null;
124 return $this->
html2wt( $pageConfig,
128 return $this->
pb2pb( $attribs );