\Dewdrop\Db\FieldInputFilterBuilder

This class adds default filters and validators to a field's input filter, depending upon its type.

Summary

Methods
Properties
Constants
createInputForField()
No public properties found
No constants found
instantiateInput()
attachForManyToMany()
attachForString()
attachForTimestamp()
attachForDate()
attachForBoolean()
attachForInteger()
attachForFloat()
$types
$metadata
N/A
No private methods found
No private properties found
N/A

Properties

$types

$types : array

The types for which we'll be handling adding inputs/filters.

Type

array

$metadata

$metadata : array

Metadata from the DB for the provided field.

Type

array

Methods

createInputForField()

createInputForField(\Dewdrop\Db\Field  $field, array  $metadata) : \Zend\InputFilter\Input

Examine the field's type and attach filters and validators accordingly.

Parameters

\Dewdrop\Db\Field $field
array $metadata

Returns

\Zend\InputFilter\Input

instantiateInput()

instantiateInput(\Dewdrop\Db\Field  $field) : \Zend\InputFilter\Input

Instantiate an Input object for the supplied field call setAllowEmpty() depending upon whether the field is required.

Parameters

\Dewdrop\Db\Field $field

Returns

\Zend\InputFilter\Input

attachForManyToMany()

attachForManyToMany(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

The only reason we provide a special case for ManyToMany, really, is to avoid the normal integer filters/validators being applied to what will not be a scalar value.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForString()

attachForString(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

Attach validators and filters for strings. If a length is specified in the DB metadata, we use that to add a StringLength validator. We always add filters to trim strings and convert empty strings to null.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForTimestamp()

attachForTimestamp(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

Attach validator for timestamp fields.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForDate()

attachForDate(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

Attach validator for date fields.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForBoolean()

attachForBoolean(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

For booleans, we handle filtering differently depending upon whether the column is nullable in the DB. If it's nullable, we try to enable use of all three possible states (null, false and true) by filtering empty strings or null values to null and filtering other values ("0", 0, false, "1", etc.) to an integer of zero or one that can be used nicely with the DB to communicate the boolean value. If the DB column is not nullable, we convert all values to integers.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForInteger()

attachForInteger(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

Ensure integer fields are filtered to ints.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input

attachForFloat()

attachForFloat(\Zend\InputFilter\Input  $input) : \Zend\InputFilter\Input

Ensure float fields are filtered to floats.

Parameters

\Zend\InputFilter\Input $input

Returns

\Zend\InputFilter\Input