public function typecastLoadField(Field $f, $value)
{
// use $f->typecast = [typecast_save_callback, typecast_load_callback]
if (is_array($f->typecast) && isset($f->typecast[1]) && is_callable($t = $f->typecast[1])) {
return $t($value, $f, $this);
}
// only string type fields can use empty string as legit value, for all
// other field types empty value is the same as no-value, nothing or null
if ($f->type && $f->type != 'string' && $value === '') {
return;
}
// we respect null values
if ($value === null) {
return;
}
// run persistence-specific typecasting of field value
return $this->_typecastLoadField($f, $value);
}