Get entity column=>value array.
@param Entity $entity
@param boolean $strict Check for constraints. Default true.
@param array $only Only column names provided. Default all.
@return array

@throws ConstraintViolationException
772836
private function getEntityDataArray($entity, $strict = true, $only = array())
    {
        $data = array();

        $structure = $this->getEntityStructure($entity);
        $columns = $structure->columns;

        foreach ($columns as $column) {
            if (count($only) > 0 && ! in_array($column->name, $only)) continue; // Ignore, we don't want this column!

            if (isset($entity->{$column->propertyName}) && $entity->{$column->propertyName} !== null) {
                $data[$column->name] = $entity->{$column->propertyName};
            } elseif (! isset($entity->{$column->propertyName}) && $entity->{$column->propertyName} === null) {
                // Throw exception if null not allowed and in strict mode.
                if ($strict && ! $column->null && ! $column->autoIncrement && $column->default === null) {
                    throw new ConstraintViolationException("Column '".$column->propertyName."' can't be empty! Null not allowed!");
                }

                // Fill in default value if allowed
                if (! $column->null && ! $column->autoIncrement && $column->default !== null) {
                    $data[$column->name] = $column->defaultValue();
                } else {
                    $data[$column->name] = null;
                }
            } else {
                $data[$column->name] = null;
            }
        }
        return $data;
    }
905869
public function getAllVersionsOfEntity(DocumentationEntity $entity)
    {
        $all = new ArrayList();

        foreach ($this->getEntities() as $check) {
            if ($check->getKey() == $entity->getKey()) {
                if ($check->getLanguage() == $entity->getLanguage()) {
                    $all->push($check);
                }
            }
        }

        return $all;
    }
795144
protected function getTableColumns($entity)
    {
        $columnClause = [];

        // Get all columns for insertion
        $allColumns = array_merge($this->requiredTableColumns($entity), $this->columns);

        // Set values for columns
        foreach ($allColumns as $col => $type) {
            $columnClause[$col] = isset($this->columns[$col]) ?
                $this->quoteOrNot($this->columns[$col]) :
                $this->sampleData($type);
        }

        $columnNames = implode(', ', array_keys($columnClause));
        $columnValues = implode(', ', $columnClause);

        return [$columnNames, $columnValues];
    }
506524
public function getEntitiesBy(array $criteria = [], array $orders = [], $limit = null, $offset = null): array
    {
        $entities = $this->getRepository()->findBy($criteria, $orders, $limit, $offset);
        $this->prepareEntitesForGet($entities);

        return $entities;
    }
338776
@Override
    public Long get(Entity entity) {
        Objects.requireNonNull(entity, "entity cannot be null");
        // return property value
        return entity.get(idFieldName).asLong();
    }
559558
public function getFromEntity($entity, array $formParameters, $limitFields = null)
    {
        $extracted_data = array();

        foreach($formParameters as $field) {
            $getter_name = "get".$this->dashesToCamelCase($field);

            if (($limitFields === null || in_array($field, $limitFields)) && method_exists($entity, $getter_name) && ($value = $entity->$getter_name()) !== null) {
                $extracted_data[$field] = $value;
            }
        }

        return $extracted_data;
    }
954576
protected function generateExtensionFields(Entity $entity)
    {
        $properties = [];
        $descriptor = $entity->getDescriptor();
        $extensions = $descriptor->getExtensionList() ?: [];

        foreach ($extensions as $field) {
            $properties[] = $this->generateExtensionField($entity, $field);
        }

        return $properties;
    }
1342375
public function getByPropertyValues($property, $values, $strict = false)
    {
        $results = [];
        foreach ($this as $item) {
            foreach ($values as $value) {
                if ($strict) {
                    if ($item->$property === $value) {
                        $results[] = $item;
                    }
                } else {
                    if ($item->$property == $value) {
                        $results[] = $item;
                    }
                }
            }
        }
        return new static($results);
    }
989527
private function getPropertiesByType($entity, $type)
    {
        $properties = $this->readClassProperties($entity);

        $fields = [];
        foreach ($properties as $property) {
            $annotation = $this->reader->getPropertyAnnotation($property, $type);

            if (null === $annotation) {
                continue;
            }

            $property->setAccessible(true);
            $annotation->value = $property->getValue($entity);
            $annotation->name = $property->getName();

            $fields[] = $annotation;
        }

        return $fields;
    }
459059
private function findFieldCriteria(array $criteria, Constraint $constraint, ObjectManager $em, ClassMetadata $class, $entity, $fieldName)
    {
        $this->validateFieldCriteria($class, $fieldName);

        /* @var \Doctrine\ORM\Mapping\ClassMetadata $class */
        $criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);

        /** @var UniqueEntity $constraint */
        if ($constraint->ignoreNull && null === $criteria[$fieldName]) {
            $criteria = null;
        } else {
            $this->findFieldCriteriaStep2($criteria, $em, $class, $fieldName);
        }

        return $criteria;
    }
886073
protected function validateEntity($entity)
    {
        $errors = Validation::createValidatorBuilder()
            ->enableAnnotationMapping()
            ->getValidator()
            ->validate($entity);

        if ($errors->count() > 0) {
            throw RestException::createFromConstraintViolationList($errors);
        }

        return $entity;
    }
922807
public function all($entity)
    {
        $reflectionClass = new \ReflectionClass($entity);
        $properties = $reflectionClass->getProperties();

        $class = new \ReflectionClass($entity);

        while ($parent = $class->getParentClass()) {
            $parentProperties = $parent->getProperties();
            $properties = array_merge($parentProperties, $properties);
            $class = $parent;
        }

        $return = array();
        foreach ($properties as $reflectionProperty) {
            $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $this->annotationClass);
            if (!is_null($propertyAnnotation) && $propertyAnnotation->listable) {
                $return[] = array(
                    'property' => $reflectionProperty->name,
                    'type' => $propertyAnnotation->type
                );
            }
        }

        return $return;
    }
925907
protected function generateGetExtensionsMethod(Entity $entity)
    {
        $lines      = [];
        $descriptor = $entity->getDescriptor();
        $fieldName  = $this->getUniqueFieldName($descriptor, 'extensions');

        $lines[] = 'if ( $this->' . $fieldName . ' !== null) {';
        $lines[] = '    return $this->' . $fieldName . ';';
        $lines[] = '}';
        $lines[] = null;
        $lines[] = 'return $this->' . $fieldName . ' = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);';

        return MethodGenerator::fromArray([
            'name'       => 'extensions',
            'body'       => implode(PHP_EOL, $lines),
            'docblock'   => [
                'shortDescription' => "{@inheritdoc}"
            ]
        ]);
    }
462685
protected function validValue(Entity $entity)
    {
        foreach ($entity->getFields() as $field => $detail) {
            $value = $entity[$field];

            // Convert value type
            if ($value instanceof \DateTimeInterface) {
                $value = $value->format($this->db->getDateFormat());
            }

            if ($value instanceof JsonSerializer) {
                $value = json_encode($value);
            }

            if (\is_object($value) && \is_callable([$value, '__toString'])) {
                $value = (string) $value;
            }

            // Start prepare default value
            if (is_array($value) || is_object($value)) {
                $value = null;
            }

            if ($value === null) {
                // This field is null and the db column is not nullable, use db default value.
                if (strtolower($detail->Null) === 'no') {
                    $entity[$field] = $detail->Default;
                }
            } else {
                // Convert to correct type.
                $dataType = DataType::getInstance($this->db->getName());

                $type = explode(' ', $detail->Type)[0];
                $type = explode('(', $type)[0];

                settype($value, $dataType::getPhpType($type));

                $entity[$field] = $value;
            }
        }

        return $entity;
    }
546477
public function load(Entity $entity)
    {
        /** @var \Slick\Orm\Sql\Select $sql */
        $sql = call_user_func_array(
            array($this->getRelatedEntity(), 'find'),
            []
        );
        $pmk = $this->getEntity()->getPrimaryKey();
        $table = Entity\Manager::getInstance()->get($this->getRelatedEntity())
            ->getEntity()->getTableName();
        $sql->where(
            [
                "{$table}.{$this->getForeignKey()} = :id" => [
                    ':id' => $this->getEntity()->$pmk
                ]
            ]
        );
        return $sql->first();
    }
466297
public function get($entity)
    {
        $key = $this->mapping['fieldname'];
        $valueMethod = 'get' . ucfirst($key);
        $value = $entity->$valueMethod();

        return $value;
    }
1188245
protected function getEntityMapInstanceFor($entity)
    {
        // First, we'll try to load the entity map from cache, to
        // save from time consuming parsing of the relationships
        $entityMap = $this->getEntityMapInstanceFromCache($entity);

        if ($entityMap !== null) {
            return $entityMap;
        }

        if (class_exists($entity.'Map')) {
            $map = $entity.'Map';
            $map = new $map();

            return $map;
        }

        if ($map = $this->getMapFromNamespaces($entity)) {
            return $map;
        }

        if ($this->strictMode) {
            throw new EntityMapNotFoundException("No Map registered for $entity");
        }

        $map = $this->getNewEntityMap();

        return $map;
    }