Creates an Entity from the raw data array with the field name
as keys and field values as values.

@param array $row
the array with the raw data

@return Entity
the entity containing the array data then
490848
protected function hydrate(array $row)
    {
        $fieldNames = $this->definition->getFieldNames(true);
        $entity     = new Entity($this->definition);
        foreach ($fieldNames as $fieldName) {
            $entity->set($fieldName, $row[$fieldName]);
        }
        return $entity;
    }
159122
public function create(array $row = null)
    {
        $result = clone $this->tableGateway->getResultSetPrototype()->getArrayObjectPrototype();
        if (!$result instanceof RowGatewayInterface) {
            throw new \RuntimeException('ArrayObject Prototype is not instanceof RowGatewayInterface');
        }
        $row && $result->populate($row + $result->toArray(), isset($row[current($this->getPrimary())]));
        return $result;
    }
1099339
private function getAgentFromRow(array $row)
    {
        if (isset($row['headers']['User-Agent'])) {
            return $row['headers']['User-Agent'];
        }

        if (class_exists('\http\Header')) {
            // pecl_http versions 2.x/3.x
            $headers = \http\Header::parse($row['headers']);
        } elseif (function_exists('\http_parse_headers')) {
            // pecl_http version 1.x
            $headers = \http_parse_headers($row['headers']);
        } else {
            return '';
        }

        if (isset($headers['User-Agent'])) {
            return $headers['User-Agent'];
        }

        return '';
    }
35539
protected function cleanupRow($row)
    {
        foreach ($row as $key => $column) {
            if ($this->isQuoted($column)) {
                $column = $this->unescape($this->unquote($column));
            }
            if ($this->isSerialized($column)) {
                $column = $this->unserialize($column);
            }
            if ('N;' === $column) {
                $column = null;
            }
            $row[$key] = $column;
        }

        return $row;
    }
1146086
public function addRow(array $row)
    {
        if (is_array($this->fields)) {
            $assoc = $row;
            $row = [];
            foreach ($this->fields as $field) {
                $row[] = isset($assoc[$field]) ? $assoc[$field] : "";
            }
        }

        $this->data[] = $row;

        return $this;
    }
1269951
protected function serializeFields(array $row)
    {
        $data    = array();
        $columns = $this->getColumns();

        $builder = $this->newQueryBuilder($this->getName());
        $parts   = $builder->getQueryPart('from');
        $part    = reset($parts);
        $alias   = $part['alias'];

        foreach ($columns as $name => $type) {
            if (!empty($alias)) {
                $pos = strpos($name, $alias . '.');
                if ($pos !== false) {
                    $name = substr($name, strlen($alias) + 1);
                }
            }

            if (isset($row[$name])) {
                $data[$name] = $this->serializeType($row[$name], $type);
            }
        }

        return $data;
    }
682961
public function getPersistedEntityFor(Row $row)
    {
        $entityInstanceHash = array_search($row, $this->persistedEntityRows, true);

        if (!$entityInstanceHash) {
            return null;
        }

        return $this->persistedEntities[$entityInstanceHash];
    }
741545
public function marshal($row)
    {
        foreach ($this->_props as $key=>$prop) {
            if (isset($row[$key])) {
                $row[$key] = $prop->type->marshal($row[$key]);
            }
        }

        return $row;
    }
196759
public function execute($row, $name = null)
    {
        parent::execute($row, $name);
        return $row[MemberNames::ENTITY_ID];
    }
483431
protected function populateItem($row)
    {
        $class = $row['type'] == Item::TYPE_PERMISSION ? Permission::className() : Role::className();

        if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
            $data = null;
        }

        return new $class([
            'name' => $row['name'],
            'type' => $row['type'],
            'description' => $row['description'],
            'ruleName' => $row['rule_name'],
            'data' => $data,
            'createdAt' => $row['created_at'],
            'updatedAt' => $row['updated_at'],
            'parents' => isset($row['parents']) ? $row['parents'] : null,
        ]);
    }
572055
public static function formatRowByType(array $row, string $className): array
    {
        $rowAry   = [];
        $entities = EntityCollector::getCollector();
        if (!isset($entities[$className])) {
            return $row;
        }

        if (strpos($className, '\\') === false) {
            $className = $entities[$className];
        }
        foreach ($row as $name => $value) {
            $field = $entities[$className]['column'][$name];
            $type  = $entities[$className]['field'][$field]['type'];

            $rowAry[$name] = self::trasferTypes($type, $value);
        }

        return $rowAry;
    }
70063
public function process(array $row)
    {
        foreach ($row as &$item) {
            if ($item instanceof DateTimeInterface) {
                $item = $item->format($this->format);
            }
        }

        return $row;
    }
743633
public function createDataObject($row)
    {
        // remove any composed fields
        $add = [];

        if ($this->_compositeExtraFields) {
            foreach ($this->_compositeExtraFields as $fieldName => $composed) {
                // convert joined extra fields into their composite field types.
                $value = [];

                foreach ($composed as $subField) {
                    if (isset($row[$fieldName . $subField])) {
                        $value[$subField] = $row[$fieldName . $subField];

                        // don't duplicate data in the record
                        unset($row[$fieldName . $subField]);
                    }
                }

                $obj = Injector::inst()->create($this->extraFields[$fieldName], $fieldName);
                $obj->setValue($value, null, false);
                $add[$fieldName] = $obj;
            }
        }

        $dataObject = parent::createDataObject($row);

        foreach ($add as $fieldName => $obj) {
            $dataObject->$fieldName = $obj;
        }

        return $dataObject;
    }
183621
protected function instantiateRowWrapperObject($row)
    {
        if ($this->row_wrapper_class === null) {
            $object = $row;
        } else {
            $object = new $this->row_wrapper_class(
                $row,
                $this->getOption('read_only')
            );
        }

        return $object;
    }
811553
protected function instantiateItem(array $row)
    {
        if ( ! count($this->intermediateFields)) {
            return parent::instantiateItem($row);
        }

        $itemAttributes         = Arr::only($row, $this->itemFields);
        $intermediateAttributes = Arr::only($row, $this->intermediateFields);
        /** @var \Colibri\Database\Model $item */
        $item = new static::$itemClass($itemAttributes);

        return $item->setIntermediate($intermediateAttributes);
    }
777014
public function populate($rows)
    {
        $indexBy = $this->indexBy;

        if ($indexBy === null) {
            return $this->createObjects($rows);
        }
        $result = [];
        foreach ($rows as $row) {
            if (is_string($indexBy)) {
                $key = $row[$indexBy];
            } else {
                $key = call_user_func($indexBy, $row);
            }
            $result[$key] = $this->createObject($row);
        }
        return $result;
    }
539381
public final function entity(array $data = []): Entity
    {
        $entity = new Entity($this, $data);
        if (method_exists($this, 'onEntity')) {
            $this->onEntity($entity);
        }

        return $entity;
    }