Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseInputFilter Class Reference

Public Member Functions

 init ()
 This function is automatically called when creating element with factory.
 
 count ()
 Countable: number of inputs in this input filter.
 
 add ($input, $name=null)
 Add an input to the input filter.
 
 replace ($input, $name)
 Replace a named input.
 
 get ($name)
 Retrieve a named input.
 
 has ($name)
 Test if an input or input filter by the given name is attached.
 
 remove ($name)
 Remove a named input.
 
 setData ($data)
 Set data to use when validating and filtering.
 
 isValid ($context=null)
 Is the data set valid?
 
 setValidationGroup ($name)
 Provide a list of one or more elements indicating the complete set to validate.
 
 getInvalidInput ()
 Return a list of inputs that were invalid.
 
 getValidInput ()
 Return a list of inputs that were valid.
 
 getValue ($name)
 Retrieve a value from a named input.
 
 getValues ()
 Return a list of filtered values.
 
 getRawValue ($name)
 Retrieve a raw (unfiltered) value from a named input.
 
 getRawValues ()
 Return a list of unfiltered values.
 
 getMessages ()
 Return a list of validation failure messages.
 
 hasUnknown ()
 Is the data set has unknown input ?
 
 getUnknown ()
 Return the unknown input.
 
 getInputs ()
 Get an array of all inputs.
 
 merge (BaseInputFilter $inputFilter)
 Merges the inputs from an InputFilter into the current one.
 
- Public Member Functions inherited from InputFilterInterface
 isValid ()
 Is the data set valid?
 

Protected Member Functions

 validateInputs (array $inputs, $data=[], $context=null)
 Validate a set of inputs against the current data.
 
 validateValidationGroup (array $inputs)
 Ensure all names of a validation group exist as input in the filter.
 
 populate ()
 Populate the values of all attached inputs.
 

Protected Attributes

 $data
 
 $inputs = []
 
 $invalidInputs
 
 $validationGroup
 
 $validInputs
 

Additional Inherited Members

- Public Attributes inherited from InputFilterInterface
const VALIDATE_ALL = 'INPUT_FILTER_ALL'
 

Member Function Documentation

add (   $input,
  $name = null 
)

Add an input to the input filter.

Parameters
InputInterface | InputFilterInterface$input
null | string$nameName used to retrieve this input
Exceptions
Exception\InvalidArgumentException
Returns
InputFilterInterface

Implements InputFilterInterface.

count ( )

Countable: number of inputs in this input filter.

Only details the number of direct children.

Returns
int
get (   $name)

Retrieve a named input.

Parameters
string$name
Exceptions
Exception\InvalidArgumentException
Returns
InputInterface|InputFilterInterface

Implements InputFilterInterface.

getInputs ( )

Get an array of all inputs.

Returns
InputInterface[]|InputFilterInterface[]
getInvalidInput ( )

Return a list of inputs that were invalid.

Implementations should return an associative array of name/input pairs that failed validation.

Returns
InputInterface[]

Implements InputFilterInterface.

getMessages ( )

Return a list of validation failure messages.

Should return an associative array of named input/message list pairs. Pairs should only be returned for inputs that failed validation.

Returns
array

Implements InputFilterInterface.

getRawValue (   $name)

Retrieve a raw (unfiltered) value from a named input.

Parameters
string$name
Exceptions
Exception\InvalidArgumentException
Returns
mixed

Implements InputFilterInterface.

getRawValues ( )

Return a list of unfiltered values.

List should be an associative array of named input/value pairs, with the values unfiltered.

Returns
array

Implements InputFilterInterface.

getUnknown ( )

Return the unknown input.

Exceptions
Exception\RuntimeException
Returns
array

Implements UnknownInputsCapableInterface.

getValidInput ( )

Return a list of inputs that were valid.

Implementations should return an associative array of name/input pairs that passed validation.

Returns
InputInterface[]

Implements InputFilterInterface.

getValue (   $name)

Retrieve a value from a named input.

Parameters
string$name
Exceptions
Exception\InvalidArgumentException
Returns
mixed

Implements InputFilterInterface.

getValues ( )

Return a list of filtered values.

List should be an associative array, with the values filtered. If validation failed, this should raise an exception.

Returns
array

Implements InputFilterInterface.

has (   $name)

Test if an input or input filter by the given name is attached.

Parameters
string$name
Returns
bool

Implements InputFilterInterface.

hasUnknown ( )

Is the data set has unknown input ?

Exceptions
Exception\RuntimeException
Returns
bool

Implements UnknownInputsCapableInterface.

init ( )

This function is automatically called when creating element with factory.

It allows to perform various operations (add elements...)

Returns
void

Implements InitializableInterface.

isValid (   $context = null)

Is the data set valid?

Parameters
mixed | null$context
Exceptions
Exception\RuntimeException
Returns
bool
merge ( BaseInputFilter  $inputFilter)

Merges the inputs from an InputFilter into the current one.

Parameters
BaseInputFilter$inputFilter
Returns
self
populate ( )
protected

Populate the values of all attached inputs.

Returns
void
remove (   $name)

Remove a named input.

Parameters
string$name
Returns
InputFilterInterface

Implements InputFilterInterface.

replace (   $input,
  $name 
)

Replace a named input.

Parameters
mixed$inputAny of the input types allowed on add() method.
string$nameName of the input to replace
Exceptions
Exception\InvalidArgumentExceptionIf input to replace not exists.
Returns
self

Implements ReplaceableInputInterface.

setData (   $data)

Set data to use when validating and filtering.

Parameters
array | Traversable$data
Exceptions
Exception\InvalidArgumentException
Returns
InputFilterInterface

Implements InputFilterInterface.

setValidationGroup (   $name)

Provide a list of one or more elements indicating the complete set to validate.

When provided, calls to isValid() will only validate the provided set.

If the initial value is VALIDATE_ALL, the current validation group, if any, should be cleared.

Implementations should allow passing a single array value, or multiple arguments, each specifying a single input.

Parameters
mixed$name
Exceptions
Exception\InvalidArgumentException
Returns
InputFilterInterface

Implements InputFilterInterface.

validateInputs ( array  $inputs,
  $data = [],
  $context = null 
)
protected

Validate a set of inputs against the current data.

Parameters
string[]$inputs Array of input names.
array | ArrayAccess$data
mixed | null$context
Returns
bool
validateValidationGroup ( array  $inputs)
protected

Ensure all names of a validation group exist as input in the filter.

Parameters
string[]$inputs Input names
Returns
void
Exceptions
Exception\InvalidArgumentException

Member Data Documentation

$data
protected
$inputs = []
protected
$invalidInputs
protected
$validationGroup
protected
$validInputs
protected