atk4\data\Persistence::typecastLoadRow PHP Method

typecastLoadRow() public method

NOTE: Please DO NOT perform "actual" field mapping here, because data may be "aliased" from SQL persistences or mapped depending on persistence driver.
public typecastLoadRow ( Model $m, array $row ) : array
$m Model
$row array
return array
    public function typecastLoadRow(Model $m, $row)
    {
        if (!$row) {
            return $row;
        }
        $result = [];
        foreach ($row as $key => &$value) {
            // Look up field object
            $f = $m->hasElement($key);
            // We have no knowledge of the field, it wasn't defined, so
            // we will leave it as-is.
            if (!$f) {
                $result[$key] = $value;
                continue;
            }
            // ignore null values
            if ($value === null) {
                continue;
            }
            // serialize if we explicitly want that
            if ($f->serialize) {
                $value = $this->serializeLoadField($f, $value);
            }
            // typecast if we explicitly want that or there is not serialization enabled
            if ($f->typecast || $f->typecast === null && $f->serialize === null) {
                $value = $this->typecastLoadField($f, $value);
            }
            // store converted value
            $result[$key] = $value;
        }
        return $result;
    }