@param object                                $entity Entity
@param \Darvin\AdminBundle\Metadata\Metadata $meta   Metadata

@return array
776790
private function buildBodyRowAttr($entity, Metadata $meta)
    {
        $attr = [];

        foreach ($meta->getConfiguration()['index_view_row_attr'] as $property) {
            $attr['data-'.$property] = $this->propertyAccessor->getValue($entity, $property);
        }

        return $attr;
    }
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;
    }
801971
public function getObjectAclEntriesAsArray($entity)
    {
        $result = array();
        foreach ($this->getObjectAclEntries($entity) as $aclEntry) {
            $result[] = new AclEntry($aclEntry->getSecurityIdentity());
        }
        return $result;
    }
1140216
protected function getExistingFields($entity)
    {
        /** @var FieldValueRepository $repo */
        $repo = $this->em->getRepository(Entity\FieldValue::class);

        return $repo->getExistingFields($entity->getId(), $entity->getContenttype(), $this->mapping['fieldname']);
    }
1324682
private function extractIdAndType(EntityMetadata $metadata, array &$data)
    {
        $identifier = $this->extractField(Persister::IDENTIFIER_KEY, $data);
        unset($data[Persister::IDENTIFIER_KEY]);

        $key = Persister::POLYMORPHIC_KEY;
        $type = $this->extractType($metadata, $data);
        if (isset($data[$key])) {
            unset($data[$key]);
        }
        return [$identifier, $type];
    }
15211
public function transform($entity)
    {   
        if (null === $entity || '' === $entity) {
            return null;
        }
        
        if (!is_object($entity)){
            throw new UnexpectedTypeException($entity, 'object');
        }
        
        if ($entity instanceof Proxy && !$entity->__isInitialized()){
            $entity->__load();
        }

        $meta = $this->om->getClassMetadata(get_class($entity));
        $id = $meta->getSingleIdReflectionProperty()->getValue($entity);

        return $id;
    }
361710
public function getEntityArrayValues($entity)
    {
        $values = [];
        $properties = $this->getEntityProperties($entity);
        $metadata = $this->em->getClassMetadata(get_class($entity));
        foreach ($properties as $property) {
            $values[$property] = $metadata->getFieldValue($entity, $property);
        }
        return $values;
    }
1188238
public static function fromEntity(FieldMetadata $meta, $entity) {
        $instance = new static($meta, $entity->getAttribute($meta->name));

        return $instance;
    }
558801
public function createPropertyForm(Metadata $meta, $property, $entity)
    {
        $dataClass = $meta->getEntityClass();

        if (!empty($entity) && !$this->propertyAccessor->isWritable($entity, $property) && null !== $meta->getTranslationClass()) {
            /** @var \Knp\DoctrineBehaviors\Model\Translatable\Translatable $entity */
            $translations = $entity->getTranslations();

            /** @var \Knp\DoctrineBehaviors\Model\Translatable\Translation $translation */
            foreach ($translations as $translation) {
                if ($translation->getLocale() === $entity->getCurrentLocale()) {
                    $dataClass = $meta->getTranslationClass();
                    $entity = $translation;
                }
            }
        }

        return $this->genericFormFactory->createNamed($meta->getFormTypeName().'_property', BaseType::class, $entity, [
            'action_type'       => 'index',
            'data_class'        => $dataClass,
            'field_filter'      => $property,
            'metadata'          => $meta,
            'required'          => false,
            'validation_groups' => [
                'Default',
                'AdminUpdateProperty',
            ],
        ]);
    }
137497
public function loadInformation($entity)
    {
        $className = $this->getClass($entity);

        if (!is_object($entity)) {
            $reflectionClass = new \ReflectionClass($className);
            if (!$reflectionClass->isInstantiable()) {
                throw new SolrMappingException(sprintf('Cannot instantiate entity %s', $className));
            }
            $entity = $reflectionClass->newInstanceWithoutConstructor();
        }

        if (!$this->annotationReader->hasDocumentDeclaration($entity)) {
            throw new SolrMappingException(sprintf('no declaration for document found in entity %s', $className));
        }

        $fields = array_merge($this->annotationReader->getFields($entity), $this->annotationReader->getMethods($entity));

        $metaInformation = new MetaInformation();
        $metaInformation->setEntity($entity);
        $metaInformation->setClassName($className);
        $metaInformation->setDocumentName($this->getDocumentName($className));
        $metaInformation->setFieldMapping($this->annotationReader->getFieldMapping($entity));
        $metaInformation->setFields($fields);
        $metaInformation->setRepository($this->annotationReader->getRepository($entity));
        $metaInformation->setIdentifier($this->annotationReader->getIdentifier($entity));
        $metaInformation->setBoost($this->annotationReader->getEntityBoost($entity));
        $metaInformation->setSynchronizationCallback($this->annotationReader->getSynchronizationCallback($entity));
        $metaInformation->setIndex($this->annotationReader->getDocumentIndex($entity));
        $metaInformation->setIsDoctrineEntity($this->isDoctrineEntity($entity));
        $metaInformation->setDoctrineMapperType($this->getDoctrineMapperType($entity));
        $metaInformation->setNested($this->annotationReader->isNested($entity));

        $fields = $this->annotationReader->getFields($entity);
        foreach ($fields as $field) {
            if (!$field->nestedClass) {
                continue;
            }

            $nestedObjectMetainformation = $this->loadInformation($field->nestedClass);

            $subentityMapping = [];
            $nestedFieldName = $field->name;
            foreach ($nestedObjectMetainformation->getFieldMapping() as $documentName => $fieldName) {
                $subentityMapping[$nestedFieldName . '.' . $documentName] = $nestedFieldName . '.' . $fieldName;
            }

            $rootEntityMapping = $metaInformation->getFieldMapping();
            $subentityMapping = array_merge($subentityMapping, $rootEntityMapping);
            unset($subentityMapping[$field->name]);
            $metaInformation->setFieldMapping($subentityMapping);
        }

        return $metaInformation;
    }
991110
public function getAttributes($entity)
    {
        if ($entity->has($this->idField)) {
            $hidden = array_merge($entity->getHidden(), [$this->idField]);
            $entity->setHidden($hidden);
        }

        $attributes = $entity->toArray();

        // remove associated data so it won't appear inside jsonapi `attributes`
        foreach ($this->_repository->associations() as $association) {
            $propertyName = $association->getProperty();

            if ($association->type() === Association::MANY_TO_ONE) {
                $foreignKey = $association->getForeignKey();
                unset($attributes[$foreignKey]);
            }

            unset($attributes[$propertyName]);
        }

        // dasherize attribute keys (like `created_by`) if need be
        if ($this->_view->viewVars['_inflect'] === 'dasherize') {
            foreach ($attributes as $key => $value) {
                $dasherizedKey = Inflector::dasherize($key);

                if (!array_key_exists($dasherizedKey, $attributes)) {
                    $attributes[$dasherizedKey] = $value;
                    unset($attributes[$key]);
                }
            }
        }

        return $attributes;
    }
292253
protected function prepareInsertData($entity) : array
    {
        $data = parent::prepareInsertData($entity);

        // Populate the discriminator column
        $discColumn = $this->class->discriminatorColumn;
        $tableName  = $discColumn->getTableName();
        $columnName = $discColumn->getColumnName();

        $this->columns[$columnName] = $discColumn;

        $data[$tableName][$columnName] = $this->class->discriminatorValue;

        return $data;
    }
1000854
public static function dicionario(string $entity = null)
    {
        if(file_exists(PATH_HOME . "entity/cache") && (empty($entity) || file_exists(PATH_HOME . "entity/cache/{$entity}.json"))) {
            if(empty($entity)){

                //read all dicionarios
                $list = [];
                foreach (\Helpers\Helper::listFolder(PATH_HOME . "entity/cache") as $json) {
                    if(preg_match('/^\w+\.json$/i', $json)){
                        $entity = str_replace('.json', '', $json);
                        if($dic = self::dicionario($entity))
                            $list[$entity] = $dic;
                    }
                }

                return $list;

            } else {

                //read dicionario específico
                $setor = empty($_SESSION['userlogin']['setor']) ? 0 : $_SESSION['userlogin']['setor'];
                $entidadesNaoPermitidas = \Config\Config::getEntityNotAllow();
                $entidadesNaoPermitidas = isset($entidadesNaoPermitidas[$setor]) ? $entidadesNaoPermitidas[$setor] : [];

                if(!in_array($entity, $entidadesNaoPermitidas)) {
                    return \Entity\Metadados::getDicionario($entity, true, true);
                }
            }
        }

        return null;
    }
1068997
public function getFieldMapping($entity)
    {
        $fields = $this->getPropertiesByType($entity, self::FIELD_CLASS);

        $mapping = [];
        foreach ($fields as $field) {
            $mapping[$field->getNameWithAlias()] = $field->name;
        }

        $id = $this->getIdentifier($entity);
        $mapping['id'] = $id->name;

        return $mapping;
    }
490312
public function mapObjectsToRows($objects, $meta=null, $context=null)
    {
        if (!$objects) { return []; }

        if (!$meta instanceof Meta) {
            $meta = $this->getMeta($meta ?: get_class(current($objects)));
        }

        $out = [];
        foreach ($objects as $key => $object) {
            $out[$key] = $this->mapObjectToRow($object, $meta, $context);
        }
        return $out;
    }
326073
private function getSubClassFields($meta, $value)
    {
        foreach ($meta->subClasses as $subClass) {
            $delimiter = strpos($subClass, '/') > 0 ? '/' : '\\';
            $temp = explode($delimiter, $subClass);
            $tempMeta = $this->em->getClassMetadata($subClass);
            if (end($temp) == $value) {
                return [
                    'table'       => $subClass,
                    'parentField' => $meta->getIdentifierColumnNames()[0],
                    'targetField' => $tempMeta->getIdentifierColumnNames()[0],
                    'meta'        => $tempMeta,
                ];
            }
        }
    }
474131
private function getFieldsFromEntityMetadata(ClassMetadataInfo $metadata)
    {
        $fields = (array) $metadata->fieldNames;

        // Remove the primary key field if it's not managed manually
        if (!$metadata->isIdentifierNatural()) {
            $fields = array_diff($fields, $metadata->identifier);
        }

        return $fields;
    }