atk4\data\Persistence::typecastLoadField PHP Method

typecastLoadField() public method

Cast specific field value from the way how it's stored inside persistence to a PHP format.
public typecastLoadField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
return mixed
    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);
    }