\Horde_Variables

An OO-way to access form variables.

Summary

Methods
Properties
Constants
getDefaultVariables()
__construct()
sanitize()
exists()
__isset()
offsetExists()
get()
__get()
offsetGet()
getExists()
set()
__set()
offsetSet()
remove()
__unset()
offsetUnset()
merge()
add()
filter()
count()
getIterator()
No public properties found
No constants found
_getExists()
$_expected
$_sanitized
$_vars
N/A
No private methods found
No private properties found
N/A

Properties

$_expected

$_expected : array

The list of expected variables.

Type

array

$_sanitized

$_sanitized : boolean

Has the input been sanitized?

Type

boolean

$_vars

$_vars : array

Array of form variables.

Type

array

Methods

getDefaultVariables()

getDefaultVariables(string  $sanitize = false) : \Horde_Variables

Returns a Horde_Variables object populated with the form input.

Parameters

string $sanitize

Sanitize the input variables?

Returns

\Horde_Variables

Variables object.

__construct()

__construct(array  $vars = array(), string  $sanitize = false) 

Constructor.

Parameters

array $vars

The list of form variables (if null, defaults to PHP's $_REQUEST value). If '_formvars' exists, it must be a JSON encoded array that contains the list of allowed form variables.

string $sanitize

Sanitize the input variables?

sanitize()

sanitize() 

Sanitize the form input.

exists()

exists(  $varname) 

Alias of isset().

Parameters

$varname

__isset()

__isset(string  $varname) : boolean

isset() implementation.

Parameters

string $varname

The form variable name.

Returns

boolean —

Does $varname form variable exist?

offsetExists()

offsetExists(  $field) 

Implements isset() for ArrayAccess interface.

Parameters

$field

get()

get(string  $varname, string  $default = null) : mixed

Returns the value of a given form variable.

Parameters

string $varname

The form variable name.

string $default

The default form variable value.

Returns

mixed —

The form variable, or $default if it doesn't exist.

__get()

__get(string  $varname) : mixed

Returns the value of a given form variable.

Parameters

string $varname

The form variable name.

Returns

mixed —

The form variable, or null if it doesn't exist.

offsetGet()

offsetGet(  $field) 

Implements getter for ArrayAccess interface.

Parameters

$field

getExists()

getExists(string  $varname,   $exists) : mixed

Given a variable name, returns the value and sets a variable indicating whether the value exists in the form data.

Parameters

string $varname

The form variable name.

$exists

Returns

mixed —

The form variable, or null if it doesn't exist.

set()

set(  $varname,   $value) 

Sets the value of a given form variable.

Parameters

$varname
$value

__set()

__set(string  $varname, mixed  $value) 

Sets the value of a given form variable.

Parameters

string $varname

The form variable name.

mixed $value

The value to set.

offsetSet()

offsetSet(  $field,   $value) 

Implements setter for ArrayAccess interface.

Parameters

$field
$value

remove()

remove(  $varname) 

Deletes a given form variable.

Parameters

$varname

__unset()

__unset(string  $varname) 

Deletes a given form variable.

Parameters

string $varname

The form variable name.

offsetUnset()

offsetUnset(  $field) 

Implements unset() for ArrayAccess interface.

Parameters

$field

merge()

merge(array  $vars) 

Merges a list of variables into the current form variable list.

Parameters

array $vars

Form variables.

add()

add(string  $varname, mixed  $value) : boolean

Set $varname to $value ONLY if it's not already present.

Parameters

string $varname

The form variable name.

mixed $value

The value to set.

Returns

boolean —

True if the value was altered.

filter()

filter(string  $varname) : mixed

Filters a form value so that it can be used in HTML output.

Parameters

string $varname

The form variable name.

Returns

mixed —

The filtered variable, or null if it doesn't exist.

count()

count() 

getIterator()

getIterator() 

_getExists()

_getExists(array  $array, string  $varname,   $value) : boolean

Fetch the requested variable ($varname) into $value, and return whether or not the variable was set in $array.

Parameters

array $array

The array to search in (usually either $this->_vars or $this->_expected).

string $varname

The name of the variable to look for.

$value

Returns

boolean —

Whether or not the variable was set (or, if we've checked $this->_expected, should have been set).