MediaWiki  1.34.4
LimitDef.php
Go to the documentation of this file.
1 <?php
2 
4 
15 class LimitDef extends IntegerDef {
16 
24  public function validate( $name, $value, array $settings, array $options ) {
25  if ( $value === 'max' ) {
26  if ( !isset( $options['parse-limit'] ) || $options['parse-limit'] ) {
27  $value = $this->callbacks->useHighLimits( $options )
28  ? $settings[self::PARAM_MAX2] ?? $settings[self::PARAM_MAX] ?? PHP_INT_MAX
29  : $settings[self::PARAM_MAX] ?? PHP_INT_MAX;
30  }
31  return $value;
32  }
33 
34  return parent::validate( $name, $value, $settings, $options );
35  }
36 
37  public function normalizeSettings( array $settings ) {
38  $settings += [
39  self::PARAM_MIN => 0,
40  ];
41 
42  return parent::normalizeSettings( $settings );
43  }
44 
45 }
Wikimedia\ParamValidator\TypeDef\LimitDef\normalizeSettings
normalizeSettings(array $settings)
Normalize a settings array.
Definition: LimitDef.php:37
Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX2
const PARAM_MAX2
(int) Maximum allowed value (high limits)
Definition: IntegerDef.php:70
Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX
const PARAM_MAX
(int) Maximum allowed value (normal limits)
Definition: IntegerDef.php:56
Wikimedia\ParamValidator\TypeDef\LimitDef\validate
validate( $name, $value, array $settings, array $options)
Validate the value.When ParamValidator is processing a multi-valued parameter, this will be called on...
Definition: LimitDef.php:24
Wikimedia\ParamValidator\TypeDef\LimitDef
Type definition for "limit" types.
Definition: LimitDef.php:15
Wikimedia\ParamValidator\TypeDef\IntegerDef
Type definition for integer types.
Definition: IntegerDef.php:26
Wikimedia\ParamValidator\TypeDef
Definition: BooleanDef.php:3