Go to the documentation of this file.
83 public function add( $name, $default,
$type = self::AUTO ) {
85 $option[
'default'] = $default;
86 $option[
'value'] =
null;
87 $option[
'consumed'] =
false;
89 if (
$type !== self::AUTO ) {
90 $option[
'type'] =
$type;
95 $this->options[$name] = $option;
103 public function delete( $name ) {
105 unset( $this->options[$name] );
120 if ( is_bool( $data ) ) {
122 } elseif ( is_int( $data ) ) {
124 } elseif ( is_float( $data ) ) {
126 } elseif ( is_string( $data ) ) {
128 } elseif ( is_array( $data ) ) {
146 if ( !isset( $this->options[$name] ) ) {
165 public function setValue( $name, $value, $force =
false ) {
168 if ( !$force && $value === $this->options[$name][
'default'] ) {
170 $this->options[$name][
'value'] =
null;
172 $this->options[$name][
'value'] = $value;
195 if ( $option[
'value'] !==
null ) {
196 return $option[
'value'];
198 return $option[
'default'];
209 $this->options[$name][
'value'] =
null;
223 $this->options[$name][
'consumed'] =
true;
240 foreach ( $names as $name ) {
242 $this->options[$name][
'consumed'] =
true;
272 $type = $this->options[$name][
'type'];
274 if (
$type !== self::INT &&
$type !== self::FLOAT ) {
275 throw new MWException(
"Option $name is not of type INT or FLOAT" );
279 $value = max( $min, min( $max, $value ) );
293 foreach ( $this->options as $name => $data ) {
294 if ( !$data[
'consumed'] ) {
295 if ( $all || $data[
'value'] !==
null ) {
311 foreach ( $this->options as $name => $data ) {
312 if ( $data[
'value'] !==
null ) {
313 $values[$name] = $data[
'value'];
327 foreach ( $this->options as $name => $data ) {
347 if ( !$optionKeys ) {
348 $optionKeys = array_keys( $this->options );
351 foreach ( $optionKeys as $name ) {
352 $default = $this->options[$name][
'default'];
353 $type = $this->options[$name][
'type'];
357 $value = $r->
getBool( $name, $default );
360 $value = $r->
getInt( $name, $default );
363 $value = $r->
getFloat( $name, $default );
366 $value = $r->
getText( $name, $default );
378 if ( $value !==
null ) {
379 $this->options[$name][
'value'] = $value === $default ? null : $value;
396 return isset( $this->options[$name] );
422 $this->
delete( $name );
getIntOrNull( $name)
Fetch an integer value from the input or return null if empty.
getText( $name, $default='')
Fetch a text string from the given array or return $default if it's not set.
getArray( $name, $default=null)
Fetch an array from the input or return $default if it's not set.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getInt( $name, $default=0)
Fetch an integer value from the input or return $default if not set.
getFloat( $name, $default=0.0)
Fetch a floating point value from the input or return $default if not set.
getBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.