@param string $entityClass Entity class

@return array
760555
public function detect($entityClass)
    {
        $meta = $this->metadataManager->getMetadata($entityClass);
        $config = $meta->getConfiguration();

        if (!empty($config['order_by'])) {
            return $config['order_by'];
        }

        $criteria = [];

        $treeConfig = $this->treeListener->getConfiguration($this->em, $entityClass);

        if (!empty($treeConfig)) {
            $criteria[$treeConfig['level']] = 'asc';
        }

        $sortableConfig = $this->sortableListener->getConfiguration($this->em, $entityClass);

        if (!empty($sortableConfig)) {
            $criteria[$sortableConfig['position']] = 'asc';
        }
        if (!empty($criteria)) {
            return $criteria;
        }

        return [
            $meta->getIdentifier() => 'desc',
        ];
    }
434589
private function getAnnotations($class)
    {
        $parsed = $this->getParser()->parse($class);
        if (!is_array($parsed)) {
            return [];
        }
        $context = [
            'class' => $class,
            'declaringClass' => $class,
            'type' => Context::TYPE_CLASS,
            'name' => $class
        ];
        $annotations = [];
        if (!empty($parsed['class'])) {
            foreach ($parsed['class'] as $value) {
                $anno = $this->create($value, $context);
                if ($anno) {
                    $annotations[] = $anno;
                }
            }
        }
        $map = [
            'methods' => Context::TYPE_METHOD,
            'properties' => Context::TYPE_PROPERTY
        ];
        $reflection = new \ReflectionClass($class);
        foreach ($map as $type_name => $type) {
            if (!empty($parsed[$type_name])) {
                foreach ($parsed[$type_name] as $name => $values) {
                    $reflType = $type == 'method' ? $reflection->getMethod($name)
                               : $reflection->getProperty($name);
                    $context['type'] = $type;
                    $context['name'] = $name;
                    $context['declaringClass'] = $reflType->getDeclaringClass()->getName();
                    foreach ($values as $value) {
                        $anno = $this->create($value, $context);
                        if ($anno) {
                            $annotations[] = $anno;
                        }
                    }
                }
            }
        }
        return $annotations;
    }
525511
protected function getValues($valueClass, array $entitiesById)
    {
        /** @var EntityRepository $valueRepository */
        $valueRepository = $this->entityManager->getRepository($valueClass);
        $qb = $valueRepository->createQueryBuilder('e');
        $qb
            ->addSelect('d', 'dv')
            ->join('e.data', 'd')
            ->leftJoin('e.dataValue', 'dv')
            ->where('e.data IN (:data)')
            ->setParameter('data', $entitiesById);

        return $qb->getQuery()->getResult();
    }
474443
private function getSlugMapItems($entityClass, $entityId, array $properties = [])
    {
        return $this->getSlugMapItemRepository()->getByEntityBuilder($entityClass, $entityId, $properties)->getQuery()->getResult();
    }
765742
private function getTranslationPrefix($entityClass)
    {
        if ($this->metadataManager->hasMetadata($entityClass)) {
            return $this->metadataManager->getMetadata($entityClass)->getEntityTranslationPrefix();
        }

        $entityName = $this->objectNamer->name($entityClass);

        return preg_match('/_translation$/', $entityName)
            ? preg_replace('/_translation$/', '.entity.', $entityName)
            : 'log.object.'.$this->objectNamer->name($entityClass).'.property.';
    }
289416
public function getEntityStructure($entityClassName)
    {
        if ($entityClassName instanceof Entity) {
            $reflection = new \ReflectionClass($entityClassName);
            $entityClassName = $reflection->getName();
        }

        if (! $this->isRegistered($entityClassName)) {
            $this->registerEntity($entityClassName);
        }
        return $this->entities[$entityClassName];
    }
514597
@Override
  public <T> List<T> findAll(Class<T> entityClass) {
    return findAll(Util.determineCollectionName(entityClass));
  }
512625
public function getRelationshipEntityPersister($class)
    {
        if (!array_key_exists($class, $this->relationshipEntityPersisters)) {
            $classMetadata = $this->entityManager->getRelationshipEntityMetadata($class);
            $this->relationshipEntityPersisters[$class] = new RelationshipEntityPersister($this->entityManager, $class, $classMetadata);
        }

        return $this->relationshipEntityPersisters[$class];
    }
193263
public static function generateMap($entities, $entityId, $entityClass)
    {
        $entityMap = [];
        foreach ($entities as $entity) {
            if ($entity instanceof $entityClass) {
                $entityObject = $entity;
            } else {
                $entityObject = new $entityClass;
                foreach ($entity as $key => $value) {
                    $propSetter = 'set'.ucfirst($key);
                    if (method_exists($entityObject, $propSetter)) {
                        $entityObject->$propSetter($value);
                    }
                }
            }

            if (is_null($entityId)) {
                array_push($entityMap, $entityObject);
            } else {
                $propKeyGetter = 'get'.ucfirst($entityId);
                $entityMap[$entityObject->$propKeyGetter()] = $entityObject;
            }
        }

        return $entityMap;
    }
769103
public function getEntityClass()
    {
        if (!$this->_entityClass) {
            $default = Entity::class;
            $self = get_called_class();
            $parts = explode('\\', $self);

            if ($self === __CLASS__ || count($parts) < 3) {
                return $this->_entityClass = $default;
            }

            $alias = Inflector::classify(Inflector::underscore(substr(array_pop($parts), 0, -5)));
            $name = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $alias;
            if (!class_exists($name)) {
                return $this->_entityClass = $default;
            }

            $class = App::className($name, 'Model/Entity');
            if (!$class) {
                throw new MissingEntityException([$name]);
            }

            $this->_entityClass = $class;
        }

        return $this->_entityClass;
    }
966389
private function createDescriptor($entityClass)
    {
        $descriptor = new EntityDescriptor($entityClass);
        $this->descriptors->set($entityClass, $descriptor);
        return $descriptor;
    }
541690
public static function getCodeGenerator($entityClass, $entityField = 'code')
    {
        if (!isset(self::$generators[$entityClass][$entityField])) {
            throw new \Exception("There is no registered entity code generator for class $entityClass and field $entityField");
        }

        return self::$generators[$entityClass][$entityField];
    }
771686
public function forgeEntity($data, $class = null) {
		if(empty($data)) {
			return [];
		}
		if(empty($class)) {
			$class = $this->id;
		}
		$array = ArrayHelper::toArray($data);
		$array = $this->getAlias()->decode($array);
		return $this->domain->factory->entity->create($class, $array);
	}
548712
private function getNewObjectFlagMeta($entityClass)
    {
        $meta = $this->extendedMetadataFactory->getExtendedMetadata($entityClass);

        return isset($meta['newObjectFlag']) ? $meta['newObjectFlag'] : [];
    }
902794
public function getByEntity($entityClass, $id, $locale, $object = null)
    {
        $metadata = $this->structureMetadataFactory->getStructureMetadata('page', $object->getStructureType());

        return [
            '_controller' => $metadata->getController(),
            'view' => $metadata->getView(),
            'object' => $object,
            'structure' => $this->documentToStructure($object),
        ];
    }
28416
public function getEntityListColumnType($columnTypeClass)
    {
        if (isset($this->columnTypes[$columnTypeClass])) {
            return $this->columnTypes[$columnTypeClass];
        }
        elseif (class_exists($columnTypeClass)) {
            return new $columnTypeClass();
        }
    }
1151627
protected function buildEntityService(string $modelClass): IEntityService
    {
        try {
            if (isset($this->registeredServices[$modelClass])) {
                return $this->container->make($this->registeredServices[$modelClass]);
            }

            return $this->container->make(EntityService::class, [
                'className' => $modelClass,
                'repository' => $this->repositoryFactory->getRepository($modelClass),
            ]);
        } catch (RepositoryException $exception) {
            throw new EntityServiceException($exception->getMessage(), $exception->getCode(), $exception);
        }
    }