3 namespace MediaWiki\Rest
;
6 * A handler base class which unpacks parameters from the path template and
7 * passes them as formal parameters to run().
9 * run() must be declared in the subclass. It cannot be declared as abstract
10 * here because it has a variable parameter list.
11 * @todo Declare it as abstract after dropping HHVM
13 * @package MediaWiki\Rest
15 class SimpleHandler
extends Handler
{
16 public function execute() {
17 $paramSettings = $this->getParamSettings();
18 $validatedParams = $this->getValidatedParams();
19 $unvalidatedParams = [];
21 foreach ( $this->getRequest()->getPathParams() as $name => $value ) {
22 $source = $paramSettings[$name][self
::PARAM_SOURCE
] ??
'unknown';
23 if ( $source !== 'path' ) {
24 $unvalidatedParams[] = $name;
27 $params[] = $validatedParams[$name];
31 if ( $unvalidatedParams ) {
32 throw new \
LogicException(
33 'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams )
37 // @phan-suppress-next-line PhanUndeclaredMethod
38 return $this->run( ...$params );