public function setData(array $data)
    {
        // Filter data
        foreach ($data as $key => $value) {
            if (isset($this->_data[$key])) {
                $filter = $this->_data[$key]->filter;

                //Only filter if we have a value
                if ($value !== null) {
                    if ($value !== '') {
                        if (!($filter instanceof AnFilterInterface)) {
                            $filter = AnService::get('anahita:filter.factory')->instantiate($filter);
                        }

                        $value = $filter->sanitize($value);
                    } else {
                        $value = null;
                    }

                    $this->_data[$key]->value = $value;
                }
            }
        }

        return $this;
    }
public function setData(array $data)
    {
        // Filter data
        foreach ($data as $key => $value) {
            if (isset($this->_data[$key])) {
                $filter = $this->_data[$key]->filter;

                //Only filter if we have a value
                if ($value !== null) {
                    if ($value !== '') {
                        if (!($filter instanceof AnFilterInterface)) {
                            $filter = AnService::get('anahita:filter.factory')->instantiate($filter);
                        }

                        $value = $filter->sanitize($value);
                    } else {
                        $value = null;
                    }

                    $this->_data[$key]->value = $value;
                }
            }
        }

        return $this;
    }
public function setData ( array $ data ) { // Filter data foreach ( $ data as $ key => $ value ) { if ( isset ( $ this -> _data [ $ key ] ) ) { $ filter = $ this -> _data [ $ key ] -> filter ; //Only filter if we have a value if ( $ value !== null ) { if ( $ value !== '' ) { if ( ! ( $ filter instanceof AnFilterInterface ) ) { $ filter = AnService :: get ( 'anahita:filter.factory' ) -> instantiate ( $ filter ) ; } $ value = $ filter -> sanitize ( $ value ) ; } else { $ value = null ; } $ this -> _data [ $ key ] -> value = $ value ; } } } return $ this ; }
Set the state data

This function will only filter values if we have a value. If the value
is an empty string it will be filtered to NULL.

@param   array|object    An associative array of state values by name
@return  AnConfigState
Set the state data