MediaWiki REL1_37
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.
 
 getHelpInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in human-readable format.
 
 getParamInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in a machine-readable format.
 
 getValue (ApiBase $module, string $name, $settings, array $options=[])
 Get and validate a value.
 
 knownTypes ()
 List known type names.
 
 normalizeSettings ( $settings)
 Adjust certain settings where ParamValidator differs from historical Action API behavior.
 
 validateValue (ApiBase $module, string $name, $value, $settings, array $options=[])
 Valiate a parameter value using a settings array.
 

Private Member Functions

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

Private Attributes

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

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 38 of file ApiParamValidator.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 93 of file ApiParamValidator.php.

Member Function Documentation

◆ checkSettings()

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

Check settings for the Action API.

Parameters
ApiBase$module
array$paramsAll module params to test
string$nameParameter to test
array$optionsOptions array
Returns
array As for ParamValidator::checkSettings()

Definition at line 188 of file ApiParamValidator.php.

◆ 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 171 of file ApiParamValidator.php.

◆ convertValidationException()

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

Convert a ValidationException to an ApiUsageException.

Parameters
ApiBase$module
ValidationException$ex
Exceptions
ApiUsageExceptionalways
Returns
never

Definition at line 337 of file ApiParamValidator.php.

References Wikimedia\ParamValidator\ValidationException\getFailureMessage().

◆ 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 421 of file ApiParamValidator.php.

◆ 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 405 of file ApiParamValidator.php.

◆ 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 359 of file ApiParamValidator.php.

References ApiBase\encodeParamName().

◆ knownTypes()

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

List known type names.

Returns
string[]

Definition at line 109 of file ApiParamValidator.php.

◆ mapDeprecatedSettingsMessages()

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

Map deprecated styles for messages for ParamValidator.

Parameters
array$settings
Returns
array

Definition at line 118 of file ApiParamValidator.php.

References ApiMessage\create().

◆ normalizeSettings()

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

Adjust certain settings where ParamValidator differs from historical Action API behavior.

Parameters
array | mixed$settings
Returns
array

Definition at line 148 of file ApiParamValidator.php.

◆ 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 382 of file ApiParamValidator.php.

References ApiBase\encodeParamName().

Member Data Documentation

◆ $messageConverter

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

Definition at line 44 of file ApiParamValidator.php.

◆ $paramValidator

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

Definition at line 41 of file ApiParamValidator.php.

◆ TYPE_DEFS

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

Type defs for ParamValidator.

Definition at line 47 of file ApiParamValidator.php.


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