MediaWiki  1.34.0
Wikimedia\ParamValidator\Callbacks Interface Reference

Interface defining callbacks needed by ParamValidator. More...

Inheritance diagram for Wikimedia\ParamValidator\Callbacks:

Public Member Functions

 getUploadedFile ( $name, array $options)
 Fetch data for a file upload. More...
 
 getValue ( $name, $default, array $options)
 Fetch a value from the request. More...
 
 hasParam ( $name, array $options)
 Test if a parameter exists in the request. More...
 
 hasUpload ( $name, array $options)
 Test if a parameter exists as an upload in the request. More...
 
 recordCondition (ValidationException $condition, array $options)
 Record non-fatal conditions. More...
 
 useHighLimits (array $options)
 Indicate whether "high limits" should be used. More...
 

Detailed Description

Interface defining callbacks needed by ParamValidator.

The user of ParamValidator is expected to pass an object implementing this interface to ParamValidator's constructor.

All methods in this interface accept an "options array". This is the same $options passed to ParamValidator::getValue(), ParamValidator::validateValue(), and the like and is intended for communication of non-global state.

Since
1.34 @unstable

Definition at line 20 of file Callbacks.php.

Member Function Documentation

◆ getUploadedFile()

Wikimedia\ParamValidator\Callbacks::getUploadedFile (   $name,
array  $options 
)

Fetch data for a file upload.

Parameters
string$nameParameter name of the upload
array$optionsOptions array
Returns
UploadedFileInterface|null Uploaded file, or null if there is no file for $name.

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.

◆ getValue()

Wikimedia\ParamValidator\Callbacks::getValue (   $name,
  $default,
array  $options 
)

Fetch a value from the request.

Return $default for file-upload parameters.

Parameters
string$nameParameter name to fetch
mixed$defaultDefault value to return if the parameter is unset.
array$optionsOptions array
Returns
string|string[]|mixed A string or string[] if the parameter was found, or $default if it was not.

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.

◆ hasParam()

Wikimedia\ParamValidator\Callbacks::hasParam (   $name,
array  $options 
)

Test if a parameter exists in the request.

Parameters
string$nameParameter name
array$optionsOptions array
Returns
bool True if present, false if absent. Return false for file upload parameters.

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.

◆ hasUpload()

Wikimedia\ParamValidator\Callbacks::hasUpload (   $name,
array  $options 
)

Test if a parameter exists as an upload in the request.

Parameters
string$nameParameter name
array$optionsOptions array
Returns
bool True if present, false if absent.

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.

◆ recordCondition()

Wikimedia\ParamValidator\Callbacks::recordCondition ( ValidationException  $condition,
array  $options 
)

Record non-fatal conditions.

Parameters
ValidationException$condition
array$optionsOptions array

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.

◆ useHighLimits()

Wikimedia\ParamValidator\Callbacks::useHighLimits ( array  $options)

Indicate whether "high limits" should be used.

Some settings have multiple limits, one for "normal" users and a higher one for "privileged" users. This is used to determine which class the current user is in when necessary.

Parameters
array$optionsOptions array
Returns
bool Whether the current user is privileged to use high limits

Implemented in MediaWiki\Rest\Validator\ParamValidatorCallbacks, and Wikimedia\ParamValidator\SimpleCallbacks.


The documentation for this interface was generated from the following file: