5use InvalidArgumentException;
8use Psr\Http\Message\UploadedFileInterface;
9use UtfNormal\Validator;
26 private function getParamsFromSource(
$source ) {
30 return $this->request->getPathParams();
33 return $this->request->getQueryParams();
36 wfDeprecatedMsg(
'The "post" source is deprecated, use "body" instead',
'1.43' );
37 return $this->request->getPostParams();
40 return $this->request->getParsedBody() ?? [];
43 return $this->request->getHeaders() ?? [];
46 throw new InvalidArgumentException( __METHOD__ .
": Invalid source '$source'" );
51 public function hasParam( $name, array $options ) {
52 $params = $this->getParamsFromSource( $options[
'source'] );
53 return isset( $params[$name] );
57 public function getValue( $name, $default, array $options ) {
58 $params = $this->getParamsFromSource( $options[
'source'] );
59 $value = $params[$name] ?? $default;
61 $options[
'source'] ===
'header' &&
62 $options[
'type'] ===
'string' &&
63 isset( $params[$name] )
65 $value = implode(
', ', $value );
69 if ( !isset( $options[
'raw'] ) && $options[
'source'] !==
'body' ) {
70 if ( is_string( $value ) ) {
72 $normalizedValue = Validator::cleanUp( $value );
75 $value = $normalizedValue;
83 public function hasUpload( $name, array $options ) {
84 if ( $options[
'source'] !==
'post' ) {
92 if ( $options[
'source'] !==
'post' ) {
95 $upload = $this->request->getUploadedFiles()[$name] ??
null;
96 return $upload instanceof UploadedFileInterface ? $upload :
null;
108 return $this->authority->isAllowed(
'apihighlimits' );
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.