MediaWiki REL1_34
LimitDef.php
Go to the documentation of this file.
1<?php
2
4
15class 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}
Type definition for integer types.
const PARAM_MAX2
(int) Maximum allowed value (high limits)
const PARAM_MAX
(int) Maximum allowed value (normal limits)
Type definition for "limit" types.
Definition LimitDef.php:15
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
normalizeSettings(array $settings)
Normalize a settings array.
Definition LimitDef.php:37