5use InvalidArgumentException;
8use Psr\Http\Message\UploadedFileInterface;
9use UtfNormal\Validator;
22 $this->request = $request;
23 $this->authority = $authority;
31 private function getParamsFromSource(
$source ) {
35 return $this->request->getPathParams();
38 return $this->request->getQueryParams();
41 wfDeprecatedMsg(
'The "post" source is deprecated, use "body" instead',
'1.43' );
42 return $this->request->getPostParams();
45 return $this->request->getParsedBody() ?? [];
48 throw new InvalidArgumentException( __METHOD__ .
": Invalid source '$source'" );
52 public function hasParam( $name, array $options ) {
53 $params = $this->getParamsFromSource( $options[
'source'] );
57 public function getValue( $name, $default, array $options ) {
58 $params = $this->getParamsFromSource( $options[
'source'] );
59 $value =
$params[$name] ?? $default;
62 if ( !isset( $options[
'raw'] ) && $options[
'source'] !==
'body' ) {
63 if ( is_string( $value ) ) {
65 $normalizedValue = Validator::cleanUp( $value );
68 $value = $normalizedValue;
75 public function hasUpload( $name, array $options ) {
76 if ( $options[
'source'] !==
'post' ) {
83 if ( $options[
'source'] !==
'post' ) {
86 $upload = $this->request->getUploadedFiles()[$name] ??
null;
87 return $upload instanceof UploadedFileInterface ? $upload :
null;
97 return $this->authority->isAllowed(
'apihighlimits' );
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
array $params
The job parameters.