MediaWiki  master
MediaWiki\Api\Validator\ApiParamValidator Class Reference

This wraps a bunch of the API-specific parameter validation logic. More...

Collaboration diagram for MediaWiki\Api\Validator\ApiParamValidator:

Public Member Functions

 __construct (ApiMain $main, ObjectFactory $objectFactory)
 
 checkSettings (ApiBase $module, array $params, string $name, array $options)
 Check settings for the Action API. More...
 
 getHelpInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in human-readable format. More...
 
 getParamInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in a machine-readable format. More...
 
 getValue (ApiBase $module, string $name, $settings, array $options=[])
 Get and validate a value. More...
 
 knownTypes ()
 List known type names. More...
 
 normalizeSettings ( $settings)
 Adjust certain settings where ParamValidator differs from historical Action API behavior. More...
 
 validateValue (ApiBase $module, string $name, $value, $settings, array $options=[])
 Valiate a parameter value using a settings array. More...
 

Private Member Functions

 checkSettingsMessage (ApiBase $module, string $key, $value, array &$ret)
 Check an API settings message. More...
 
 convertValidationException (ApiBase $module, ValidationException $ex)
 Convert a ValidationException to an ApiUsageException. More...
 
 mapDeprecatedSettingsMessages (array $settings)
 Map deprecated styles for messages for ParamValidator. More...
 

Private Attributes

MessageConverter $messageConverter
 
ParamValidator $paramValidator
 
const TYPE_DEFS
 Type defs for ParamValidator. More...
 

Detailed Description

This wraps a bunch of the API-specific parameter validation logic.

It's intended to be used in ApiMain by composition.

Since
1.35

Definition at line 37 of file ApiParamValidator.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Api\Validator\ApiParamValidator::__construct ( ApiMain  $main,
ObjectFactory  $objectFactory 
)

Definition at line 85 of file ApiParamValidator.php.

References ApiBase\LIMIT_SML1, and ApiBase\LIMIT_SML2.

Member Function Documentation

◆ checkSettings()

◆ checkSettingsMessage()

MediaWiki\Api\Validator\ApiParamValidator::checkSettingsMessage ( ApiBase  $module,
string  $key,
  $value,
array &  $ret 
)
private

Check an API settings message.

Parameters
ApiBase$module
string$key
mixed$value
array&$ret

Definition at line 163 of file ApiParamValidator.php.

References ApiBase\makeMessage().

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettings().

◆ convertValidationException()

MediaWiki\Api\Validator\ApiParamValidator::convertValidationException ( ApiBase  $module,
ValidationException  $ex 
)
private

◆ getHelpInfo()

MediaWiki\Api\Validator\ApiParamValidator::getHelpInfo ( ApiBase  $module,
string  $name,
  $settings,
array  $options 
)

Describe parameter settings in human-readable format.

Parameters
ApiBase$module
string$nameParameter name being described.
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array.
Returns
Message[]

Definition at line 412 of file ApiParamValidator.php.

References ApiBase\encodeParamName().

◆ getParamInfo()

MediaWiki\Api\Validator\ApiParamValidator::getParamInfo ( ApiBase  $module,
string  $name,
  $settings,
array  $options 
)

Describe parameter settings in a machine-readable format.

Parameters
ApiBase$module
string$nameParameter name.
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array.
Returns
array

Definition at line 396 of file ApiParamValidator.php.

References ApiBase\encodeParamName().

◆ getValue()

MediaWiki\Api\Validator\ApiParamValidator::getValue ( ApiBase  $module,
string  $name,
  $settings,
array  $options = [] 
)

Get and validate a value.

Parameters
ApiBase$module
string$nameParameter name, unprefixed
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array
Returns
mixed Validated parameter value
Exceptions
ApiUsageExceptionif the value is invalid

Definition at line 350 of file ApiParamValidator.php.

References MediaWiki\Api\Validator\ApiParamValidator\convertValidationException(), ApiBase\encodeParamName(), and MediaWiki\Api\Validator\ApiParamValidator\normalizeSettings().

◆ knownTypes()

MediaWiki\Api\Validator\ApiParamValidator::knownTypes ( )

List known type names.

Returns
string[]

Definition at line 101 of file ApiParamValidator.php.

◆ mapDeprecatedSettingsMessages()

MediaWiki\Api\Validator\ApiParamValidator::mapDeprecatedSettingsMessages ( array  $settings)
private

◆ normalizeSettings()

MediaWiki\Api\Validator\ApiParamValidator::normalizeSettings (   $settings)

◆ validateValue()

MediaWiki\Api\Validator\ApiParamValidator::validateValue ( ApiBase  $module,
string  $name,
  $value,
  $settings,
array  $options = [] 
)

Valiate a parameter value using a settings array.

Parameters
ApiBase$module
string$nameParameter name, unprefixed
mixed$valueParameter value
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array
Returns
mixed Validated parameter value(s)
Exceptions
ApiUsageExceptionif the value is invalid

Definition at line 373 of file ApiParamValidator.php.

References MediaWiki\Api\Validator\ApiParamValidator\convertValidationException(), ApiBase\encodeParamName(), and MediaWiki\Api\Validator\ApiParamValidator\normalizeSettings().

Member Data Documentation

◆ $messageConverter

MessageConverter MediaWiki\Api\Validator\ApiParamValidator::$messageConverter
private

Definition at line 43 of file ApiParamValidator.php.

◆ $paramValidator

ParamValidator MediaWiki\Api\Validator\ApiParamValidator::$paramValidator
private

Definition at line 40 of file ApiParamValidator.php.

◆ TYPE_DEFS

const MediaWiki\Api\Validator\ApiParamValidator::TYPE_DEFS
private

Type defs for ParamValidator.

Definition at line 46 of file ApiParamValidator.php.


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