public function processBeforeSave(array $fieldData, array $trackData)
    {
        $this->changed = false;

        if (! $this->exists) {
            return null;
        }

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $field->calculationStart($trackData);
            }
        }

        $output = array();

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $inVal  = isset($fieldData[$key]) ? $fieldData[$key] : null;
                $outVal = $field->calculateFieldValue($inVal, $fieldData, $trackData);

                if (is_array($outVal) || is_array($inVal)) {
                   if (is_array($outVal) && is_array($inVal)) {
                        $changedNow = ($outVal != $inVal);
                    } else {
                        $changedNow = true;
                    }
                } else {
                    $changedNow = ((string) $inVal !== (string) $outVal);
                }
                $this->changed = $this->changed || $changedNow;

                $fieldData[$key] = $outVal; // Make sure the new value is available to the next field
                $output[$key]    = $outVal;
            }
        }

        return $output;
    }
public function processBeforeSave(array $fieldData, array $trackData)
    {
        $this->changed = false;

        if (! $this->exists) {
            return null;
        }

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $field->calculationStart($trackData);
            }
        }

        $output = array();

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $inVal  = isset($fieldData[$key]) ? $fieldData[$key] : null;
                $outVal = $field->calculateFieldValue($inVal, $fieldData, $trackData);

                if (is_array($outVal) || is_array($inVal)) {
                   if (is_array($outVal) && is_array($inVal)) {
                        $changedNow = ($outVal != $inVal);
                    } else {
                        $changedNow = true;
                    }
                } else {
                    $changedNow = ((string) $inVal !== (string) $outVal);
                }
                $this->changed = $this->changed || $changedNow;

                $fieldData[$key] = $outVal; // Make sure the new value is available to the next field
                $output[$key]    = $outVal;
            }
        }

        return $output;
    }
public function processBeforeSave ( array $ fieldData , array $ trackData ) { $ this -> changed = false ; if ( ! $ this -> exists ) { return null ; } foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ field -> calculationStart ( $ trackData ) ; } } $ output = array ( ) ; foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ inVal = isset ( $ fieldData [ $ key ] ) ? $ fieldData [ $ key ] : null ; $ outVal = $ field -> calculateFieldValue ( $ inVal , $ fieldData , $ trackData ) ; if ( is_array ( $ outVal ) || is_array ( $ inVal ) ) { if ( is_array ( $ outVal ) && is_array ( $ inVal ) ) { $ changedNow = ( $ outVal != $ inVal ) ; } else { $ changedNow = true ; } } else { $ changedNow = ( ( string ) $ inVal !== ( string ) $ outVal ) ; } $ this -> changed = $ this -> changed || $ changedNow ; $ fieldData [ $ key ] = $ outVal ; // Make sure the new value is available to the next field $ output [ $ key ] = $ outVal ; } } return $ output ; }
Processes the values and and changes them as required

@param array $fieldData The field values
@param array $trackData The currently available track data (track id may be empty)
@return array The processed data
Processes the values and and changes them as required