public function typecastSaveField(Field $f, $value)
{
// use $f->typecast = [typecast_save_callback, typecast_load_callback]
if (is_array($f->typecast) && isset($f->typecast[0]) && is_callable($t = $f->typecast[0])) {
return $t($value, $f, $this);
}
// normalize value
$value = $f->normalize($value);
// we respect null values
if ($value === null) {
return;
}
// run persistence-specific typecasting of field value
return $this->_typecastSaveField($f, $value);
}