View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Filter_Null
{zone-data}

{zone-data:proposer-list}
[~thomas]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 14 June 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Filter_Null is a component which allows to accept empty values as NULL in case of a database useage.
{zone-data}

{zone-data:references}
[ZF-3808]
{zone-data}

{zone-data:requirements}
* This component *will* change values to be NULL
* This component *will* allow to change which values should be changed
{zone-data}

{zone-data:dependencies}
* Zend_Filter_Null
{zone-data}

{zone-data:operation}
This component will filter input values to be null. This is needed for databases when a '0' or '' is not equal to NULL.
You can edit which inputs are changed to NULL. Per default the values '' (empty string), 0 (integer or string 0), and
false (boolean false) are changed to NULL.

The filtered value itself can then savely be stored in a database without any change.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: \[DONE\] Proposal accepted
* Milestone 3: \[DONE\] Coding finished
* Milestone 4: \[DONE\] Unit tests finished
* Milestone 5: \[DONE\] Documentation finished
* Milestone 6: \[DONE\] Component moved to core
{zone-data}

{zone-data:class-list}
* Zend_Filter_Null
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
$filter = new Zend_Filter_Null();
$filter->filter(''); // returns NULL
{code}
||UC-02||
{code}
$filter = new Zend_Filter_Null(Zend_Filter_Null::ZERO_INT);
$filter->filter(0); // -> NULL
$filter->filter('0'); // -> '0' -> no change as it's no integer zero
{code}
||UC-03||
{code}
$filter = new Zend_Filter_Null(Zend_Filter_Null::ZERO_INT);
$filter->setType(Zend_Filter_Null::ZERO_INT && Zend_Filter_Null::ZERO_STRING)
->filter(0); // -> NULL
$filter->filter('0'); // -> NULL
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_Null {
const ZERO_INT;
const ZERO_STRING;
const EMPTY_STRING;
const EMPTY_ARRAY;
const FALSE_BOOLEAN;
const ALL;

public function __construct($options = ALL);
public function setType($type);
public function getType();
public function filter($value);
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>