MediaWiki  master
SimpleHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Rest;
4 
14 abstract class SimpleHandler extends Handler {
15  public function execute() {
16  $paramSettings = $this->getParamSettings();
18  $unvalidatedParams = [];
19  $params = [];
20  foreach ( $this->getRequest()->getPathParams() as $name => $value ) {
21  $source = $paramSettings[$name][self::PARAM_SOURCE] ?? 'unknown';
22  if ( $source !== 'path' ) {
23  $unvalidatedParams[] = $name;
24  $params[] = $value;
25  } else {
26  // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
27  $params[] = $validatedParams[$name];
28  }
29  }
30 
31  if ( $unvalidatedParams ) {
32  throw new \LogicException(
33  'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams )
34  );
35  }
36 
37  // @phan-suppress-next-line PhanUndeclaredMethod
38  return $this->run( ...$params );
39  }
40 }
getParamSettings()
Fetch ParamValidator settings for parameters.
Definition: Handler.php:150
$source
array null $validatedParams
Definition: Handler.php:30
getRequest()
Get the current request.
Definition: Handler.php:65
run()
Run the current MediaWiki instance; index.php just calls this.
Definition: MediaWiki.php:526
getValidatedParams()
Fetch the validated parameters.
Definition: Handler.php:169