@param $entity

@return array
331148
public function getSortableGroupsFieldByEntity($entity)
    {
        if (is_object($entity)) {
            $entity = ClassUtils::getClass($entity);
        }

        $groups = [];
        if (isset($this->sortableGroups['entities'][$entity])) {
            $groups = $this->sortableGroups['entities'][$entity];
        }

        return $groups;
    }
1254755
public function generateBody(Entity $entity)
    {
        $body       = [];
        $descriptor = $entity->getDescriptor();
        $fields     = $descriptor->getFieldList() ?: [];

        foreach ($fields as $field) {
            if ( ! $field->hasDefaultValue()) {
                continue;
            }

            $name  = $field->getName();
            $value = $this->getDefaultFieldValue($field);

            $body[] = sprintf('$this->%s = %s;', $name, $value);
        }

        $body[] = null;
        $body[] = 'parent::__construct($stream, $configuration);';

        return $body;
    }
331804
protected function getEntityDataArray(EntityInterface $entity)
    {
        $metadata = $this->getEntityMetadata();
        $array = [];
        
        foreach ($this->getHydrator()->extract($entity) as $sqlName => $value) {
            if ($sqlName !== $metadata->getIdentifier() && null !== $value) {
                $array[$metadata->getRawSQLName($metadata->getName($sqlName))] = $value;
            }
        }
        
        return $array;
    }
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;
    }
621790
public function & getEntityChangeSet($entity)
    {
        $oid  = spl_object_id($entity);
        $data = [];

        if (! isset($this->entityChangeSets[$oid])) {
            return $data;
        }

        return $this->entityChangeSets[$oid];
    }
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;
    }
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;
    }
560281
public function saveAttendee(array $entity): array
    {
        $response = [
            'status' => false,
            'errors' => [],
            'entity' => null,
        ];

        if (empty($entity['id'])) {
            unset($entity['id']);
        }

        $query = $this->find()
            ->where([
                'source' => $entity['source'],
                'source_id' => $entity['source_id'],
                'contact_details' => $entity['contact_details'],
            ]);

        $query->execute();

        if (!$query->count()) {
            $item = $this->newEntity();
            $item = $this->patchEntity($item, $entity);
        } else {
            $item = $query->firstOrFail();
            if (!($item instanceof EntityInterface)) {
                throw new RuntimeException('Expected instance of EntityInterface');
            }
            $item = $this->patchEntity($item, $entity);
        }

        $saved = $this->save($item);

        if ($saved) {
            $response['status'] = true;
            $response['entity'] = $saved;
        } else {
            $response['errors'] = $item->getErrors();
        }

        return $response;
    }
147312
public function getEntityId($entity)
    {
        $entityId = $this->idAccessorRegistry->getEntityId($entity);

        if (is_array($entityId)) {
            ksort($entityId);
            $entityId = json_encode($entityId);
        }

        return $entityId;
    }
24317
protected function getConditions(EntityInterface $entity)
    {
        $parts = explode('\\', $this->getEntityDescriptor()->className());
        $property = lcfirst(array_pop($parts));
        return [
            "rel.{$this->getForeignKey()} = :{$property}" => [
                ":{$property}" => $entity->getId()
            ]
        ];
    }
1041898
public function getEntityConfig(string $entity): array
    {
        if (!array_key_exists($entity, $this->configValues['entities'])) {
            throw new \InvalidArgumentException("$entity is not set in config");
        }

        return $this->configValues['entities'][$entity];
    }
1179578
public function getManagedFields($entity)
    {
        $class = get_class($entity);

        if (!isset($this->managedFields[$class])) {
            $entityClass = get_class($entity);
            $this->managedFields[$class] = array();
            do {
                $metadata = $this->metadataFactory->getMetadataForClass($entityClass);
                foreach ($metadata->propertyMetadata as $field => $metadata) {
                    if (isset($metadata->fileManager)) {
                        $this->managedFields[$class][] =$field;
                    }
                }
            } while ($entityClass = get_parent_class($entityClass));
            $this->managedFields[$class] = array_unique($this->managedFields[$class]);
        }
        return $this->managedFields[$class];
    }
68212
public function getEntityMetadata($entity)
    {
        if (!$this->isManagedByDoctrine($entity)) {
            return null;
        }

        $cacheKey = 'metadata';
        $entity   = $this->getEntityClassFull($entity);
        $metadata = $this->getFromCache($entity, $cacheKey);

        if (false !== $metadata) {
            return $metadata;
        }

        $metadata = $this->entityManager->getClassMetadata($entity);
        $this->cache[$metadata->getName()][$cacheKey] = $metadata;

        return $metadata;
    }
1338686
public function transform($entity)
	{
        if (!$this->isMultiple())
		{
			if (is_null($entity) || ! $entity instanceof $this->entityClass)
			{
				return '';
			}

			return strval($entity->getId());
		}

		if (is_array($entity))
		    $entity = new ArrayCollection($entity);
		if (is_iterable($entity))
			if ($entity->count() == 0)
				return [];
			else
			{
				return $entity->toArray();
			}


		if (is_object($entity) && $entity instanceof $this->entityClass)
		    return $entity->getId();

        if (is_null($entity))
            return null;

		throw new \Exception('What to do with: ' . json_encode($entity) . ' for class ' . $this->entityClass);
	}
1011483
private function getIdentifierValues($entity)
    {
        try {
            return $this->modelManager->getIdentifierValues($entity);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(sprintf('Unable to retrieve the identifier values for entity %s', \get_class($entity)), 0, $e);
        }
    }
104292
public function getMetaData($entity)
    {
        $propertyAnnotations = [];
        $result = new \stdClass;
        $class = new \ReflectionClass($entity);
        $classAnnotations = $this->_reader->getClassAnnotations($class);
        foreach ($class->getProperties() as $key => $value) {
            $annotation = $this->_reader->getPropertyAnnotations(new \ReflectionProperty($entity, $value->name));
            if (count($annotation)) {
                $propertyAnnotations[$value->name] = array_pop($annotation);
            }
        }

        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof \MercadoPago\Annotation\RestMethod) {
                $result->methods[$annotation->method] = get_object_vars($annotation);
            }
            if ($annotation instanceof \MercadoPago\Annotation\RequestParam) {
                $result->params[] = $annotation->param;
            }
            if ($annotation instanceof \MercadoPago\Annotation\DenyDynamicAttribute) {
                $result->denyDynamicAttribute = true;
            }
        }

        foreach ($propertyAnnotations as $key => $annotation) {
            if ($annotation instanceof \MercadoPago\Annotation\Attribute) {
                $result->attributes[$key] = get_object_vars($annotation);
            }
        }

        return $result;
    }
792212
protected function HLDelete($entity)
    {
        $return = [];
        $id = $this->HLGetIdByCode($entity);
        if ($id) {
            $res = HighloadBlockTable::delete($id);
            if ($res->isSuccess()) {
                $return[] = "Delete highload block {$entity} ({$id})";
            } else {
                throw new Exception("Can't delete {$entity} ({$id}) highload block: " . implode(', ', $res->getErrorMessages()));
            }
        } else {
            throw new Exception("Hl entity with name {$entity} does not exist");
        }

        return $return;
    }