Esempio n. 1
0
 function getEmptyValue($field, $fieldType)
 {
     if (str_equals_icase($fieldType, 'boolean')) {
         return FALSE;
     } else {
         if (is_array_type($fieldType)) {
             return array();
         } else {
             return null;
         }
     }
 }
Esempio n. 2
0
function get_array_component_type($type)
{
    if (is_array_type($type)) {
        return substr($type, 0, -2);
    }
    return null;
}
Esempio n. 3
0
 function &_convertValue(&$newValue, &$requiredType, &$pe, &$oldValue)
 {
     $convertedValue = $newValue;
     if ($pe != null && !is_string($convertedValue)) {
         // Not a String -> use PropertyEditor's setValue.
         // With standard PropertyEditors, this will return the very same object;
         // we just want to allow special PropertyEditors to override setValue
         // for type conversion from non-String values to the required type.
         $pe->setValue($convertedValue);
         $newConvertedValue = $pe->getValue();
         if ($newConvertedValue != $convertedValue) {
             $convertedValue =& $newConvertedValue;
             // Reset PropertyEditor: It already did a proper conversion.
             // Don't use it again for a setAsText call.
             $pe = null;
         }
     }
     if ($requiredType != null && !is_array_type($requiredType) && get_qualified_type($convertedValue) == 'string[]') {
         // Convert String array to a comma-separated String.
         // Only applies if no PropertyEditor converted the String array before.
         // The CSV String will be passed into a PropertyEditor's setAsText method, if any.
         if (log_enabled(LOG_INFO)) {
             log_message(LOG_INFO, "Converting String array to comma-delimited String [" . $convertedValue . "]");
         }
         $convertedValue = implode(',', $convertedValue);
     }
     if ($pe != null && is_string($convertedValue)) {
         // Use PropertyEditor's setAsText in case of a String value.
         if (log_enabled(LOG_INFO)) {
             log_message(LOG_INFO, "Converting String to [" . $requiredType . "] using property editor [" . get_class($pe) . "]");
         }
         $pe->setValue($oldValue);
         $pe->setAsText($convertedValue);
         $convertedValue = $pe->getValue();
     }
     return $convertedValue;
 }