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 {
18 public function execute() {
19 $paramSettings = $this->getParamSettings();
20 $validatedParams = $this->getValidatedParams();
21 $unvalidatedParams = [];
22 $params = [];
23 foreach ( $this->getRequest()->getPathParams() as $name => $value ) {
24 $source = $paramSettings[$name][self::PARAM_SOURCE] ?? 'unknown';
25 if ( $source !== 'path' ) {
26 $unvalidatedParams[] = $name;
27 $params[] = $value;
28 } else {
29 $params[] = $validatedParams[$name];
30 }
31 }
32
33 if ( $unvalidatedParams ) {
34 throw new LogicException(
35 'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams )
36 );
37 }
38
39 // @phan-suppress-next-line PhanUndeclaredMethod
40 return $this->run( ...$params );
41 }
42}
array $params
The job parameters.
run()
Run the job.
Base class for REST route handlers.
Definition Handler.php:25
getParamSettings()
Fetch ParamValidator settings for parameters.
Definition Handler.php:585
getRequest()
Get the current request.
Definition Handler.php:336
getValidatedParams()
Fetch the validated parameters.
Definition Handler.php:923
execute()
Execute the handler.
$source
  NODES