MediaWiki master
SimpleHandler.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Rest;
4
5use LogicException;
6
17abstract class SimpleHandler extends Handler {
19 public function execute() {
20 $paramSettings = $this->getParamSettings();
21 $validatedParams = $this->getValidatedParams();
22 $unvalidatedParams = [];
23 $params = [];
24 foreach ( $this->getRequest()->getPathParams() as $name => $value ) {
25 $source = $paramSettings[$name][self::PARAM_SOURCE] ?? 'unknown';
26 if ( $source !== 'path' ) {
27 $unvalidatedParams[] = $name;
28 $params[] = $value;
29 } else {
30 $params[] = $validatedParams[$name];
31 }
32 }
33
34 if ( $unvalidatedParams ) {
35 throw new LogicException(
36 'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams )
37 );
38 }
39
40 // @phan-suppress-next-line PhanUndeclaredMethod
41 return $this->run( ...$params );
42 }
43}
Base class for REST route handlers.
Definition Handler.php:25
getParamSettings()
Fetch ParamValidator settings for parameters.
Definition Handler.php:651
getRequest()
Get the current request.
Definition Handler.php:336
getValidatedParams()
Fetch the validated parameters.
Definition Handler.php:1035
execute()
Execute the handler.This is called after parameter validation. The return value can either be a Respo...
$source