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  $params[] = $validatedParams[$name];
27  }
28  }
29 
30  if ( $unvalidatedParams ) {
31  throw new \LogicException(
32  'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams )
33  );
34  }
35 
36  // @phan-suppress-next-line PhanUndeclaredMethod
37  return $this->run( ...$params );
38  }
39 }
MediaWiki\Rest\Handler\getParamSettings
getParamSettings()
Fetch ParamValidator settings for parameters.
Definition: Handler.php:180
MediaWiki\run
run()
Run the current MediaWiki instance; index.php just calls this.
Definition: MediaWiki.php:539
MediaWiki\Rest\Handler\PARAM_SOURCE
const PARAM_SOURCE
(string) ParamValidator constant to specify the source of the parameter.
Definition: Handler.php:17
MediaWiki\Rest\Handler
Definition: Handler.php:11
MediaWiki\Rest\Handler\getValidatedParams
getValidatedParams()
Fetch the validated parameters.
Definition: Handler.php:200
MediaWiki\Rest
MediaWiki\Rest\Handler\getRequest
getRequest()
Get the current request.
Definition: Handler.php:82
MediaWiki\Rest\SimpleHandler\execute
execute()
Execute the handler.
Definition: SimpleHandler.php:15
$source
$source
Definition: mwdoc-filter.php:34
MediaWiki\Rest\Handler\$validatedParams
array null $validatedParams
Definition: Handler.php:32
MediaWiki\Rest\SimpleHandler
Definition: SimpleHandler.php:14