GraphAware\Neo4j\OGM\Repository\BaseRepository::hydrateQueryRecord PHP Method

hydrateQueryRecord() private method

private hydrateQueryRecord ( QueryResultMapper $resultMapper, GraphAware\Common\Result\Record $record )
$resultMapper GraphAware\Neo4j\OGM\Metadata\QueryResultMapper
$record GraphAware\Common\Result\Record
    private function hydrateQueryRecord(QueryResultMapper $resultMapper, Record $record)
    {
        $reflClass = new \ReflectionClass($resultMapper->getClassName());
        $instance = $reflClass->newInstanceWithoutConstructor();
        foreach ($resultMapper->getFields() as $field) {
            if (!$record->hasValue($field->getFieldName())) {
                throw new \RuntimeException(sprintf('The record doesn\'t contain the required field "%s"', $field->getFieldName()));
            }
            $value = null;
            if ($field->isEntity()) {
                $value = $this->hydrate($record, false, $field->getFieldName(), ClassUtils::getFullClassName($field->getTarget(), $resultMapper->getClassName()));
            } else {
                $value = $record->get($field->getFieldName());
            }
            $property = $reflClass->getProperty($field->getFieldName());
            $property->setAccessible(true);
            $property->setValue($instance, $value);
        }
        return $instance;
    }