@param mixed $entityOrClass Entity or class

@return \Darvin\AdminBundle\Metadata\Metadata
@throws \Darvin\AdminBundle\Metadata\MetadataException
13290
public function getMetadata($entityOrClass)
    {
        $this->init();

        $entityClass = is_object($entityOrClass) ? ClassUtils::getClass($entityOrClass) : $entityOrClass;

        if (isset($this->entityOverride[$entityClass])) {
            $entityClass = $this->entityOverride[$entityClass];
        }
        if (!isset($this->metadata[$entityClass])) {
            $childClass = $entityClass;

            while ($parentClass = get_parent_class($childClass)) {
                if (isset($this->metadata[$parentClass])) {
                    $this->metadata[$entityClass] = $this->metadata[$parentClass];

                    return $this->metadata[$parentClass];
                }

                $childClass = $parentClass;
            }

            throw new MetadataException(sprintf('Unable to get metadata for class "%s".', $entityClass));
        }

        return $this->metadata[$entityClass];
    }
1158267
public function createDoctrineAdapter($adapterClass = null, $entityManagerName = null)
    {
        if (null == $adapterClass) {
            $adapterClass = 'Lexik\Bundle\CurrencyBundle\Adapter\DoctrineCurrencyAdapter';
        }
        $adapter = $this->create($adapterClass);

        $em = $this->doctrine->getManager($entityManagerName);
        $adapter->setManager($em);

        return $adapter;
    }
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',
        ];
    }
1129745
protected function getClassMetadata(string $class): ClassMetadata
    {
        $factory = $this->getDoctrineHelper()->getMetadataFactory();
        if (!$factory->hasMetadataFor($class)) {
            throw new \InvalidArgumentException(sprintf('No metadata found for class "%s"', $class));
        }
        
        return $factory->getMetadataFor($class);
    }
473302
public function generateEntityClass(ClassMetadataInfo $metadata)
    {
        $placeHolders = array(
            '<namespace>',
            '<useStatement>',
            '<entityAnnotation>',
            '<entityClassName>',
            '<entityBody>'
        );

        $replacements = array(
            $this->generateEntityNamespace($metadata),
            $this->generateEntityUse(),
            $this->generateEntityDocBlock($metadata),
            $this->generateEntityClassName($metadata),
            $this->generateEntityBody($metadata)
        );

        $code = str_replace($placeHolders, $replacements, static::$classTemplate) . "\n";

        return str_replace('<spaces>', $this->spaces, $code);
    }
810551
public function generateEntityRepositoryClass(string $entityClass, string $repositoryClass)
    {
        $variables = [
            '<namespace>' => $this->generateEntityRepositoryNamespace($repositoryClass),
            '<entityClassName>' => $entityClass,
            '<entity>' => $this->generateEntityName($entityClass),
            '<repository>' => $this->generateClassName($repositoryClass),
        ];

        return str_replace(array_keys($variables), array_values($variables), self::$_template);
    }
1016073
protected function doLoad($itemClass)
	{
		$itemMetaData = $this->newItemMetaDataInstance($itemClass);
		$entityDefinitions = $this->annotationDriver->loadEntityDefinitions($itemClass);
		$itemMetaData->mapEntities($entityDefinitions);
		$hitDefinitions = $this->annotationDriver->loadHitDefinitions($itemClass);
		$itemMetaData->mapHits($hitDefinitions);
		return $itemMetaData;
	}
599490
private function getCustomObjectMeta($entityClass)
    {
        if (!array_key_exists($entityClass, $this->customObjectMeta)) {
            $meta = $this->extendedMetadataFactory->getExtendedMetadata($entityClass);

            $this->customObjectMeta[$entityClass] = isset($meta['customObjects']) && !empty($meta['customObjects'])
                ? $meta['customObjects']
                : null;
        }

        return $this->customObjectMeta[$entityClass];
    }
983559
public function parseClass($class)
    {
        $reflectionClass = new ReflectionClass($class);

        // check if class is entity
        if ($this->reader->getClassAnnotation($reflectionClass, '\ProAI\Datamapper\Annotations\Entity')) {
            return $this->parseEntity($class);
        } else {
            return null;
        }
    }
152658
private static function getReflectionClass($objectOrClass, $classOverride = null): ReflectionClass
    {
        $class = $classOverride;
        if ($class === null) {
            if (is_object($objectOrClass)) {
                $class = get_class($objectOrClass);
            } else {
                $class = $objectOrClass;
            }
        }
        return new ReflectionClass($class);
    }
236406
public function entity(string $entityClass) : EntityMapperDefiner
    {
        return new EntityMapperDefiner($this->iocContainer, function (callable $entityMapperFactory) use ($entityClass) {
            $this->entityMapperFactories[] = $entityMapperFactory;
        });
    }
373656
public function getCollectionByDocumentClass($documentClass): Collection
    {
        $metadata = $this->metadataFactory->getClassMetadata($documentClass);

        return $this->getCollection($metadata->getCollectionName(), $metadata->getCollectionOptions());
    }
200735
public function build(string $modelClass): IEntityService
    {
        if (!isset($this->sharedInstances[$modelClass]) || $this->sharedInstances[$modelClass] === null) {
            $this->sharedInstances[$modelClass] = $this->buildEntityService($modelClass);
        }
        return $this->sharedInstances[$modelClass];
    }
561692
protected static function getObject($objectOrClass): object
    {
        self::assertParam($objectOrClass);

        if (\is_string($objectOrClass)) {
            try {
                $objectOrClass = new $objectOrClass();
            } catch (\Error $e) {
                try {
                    $class = new \ReflectionClass($objectOrClass);
                    $objectOrClass = $class->newInstanceWithoutConstructor();
                    // @codeCoverageIgnoreStart
                } catch (\ReflectionException $exception) {
                    throw new \RuntimeException(
                        '[' . typeOf($exception) . '] ' . $exception->getMessage(),
                        (int)$exception->getCode(),
                        $exception
                    );
                }
                // @codeCoverageIgnoreEnd
            }
        }
        return $objectOrClass;
    }
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.';
    }
570548
public function getRepository($class)
    {
        $classMetadata = $this->getClassMetadataFor($class);
        if (!array_key_exists($class, $this->repositories)) {
            $repositoryClassName = $classMetadata->hasCustomRepository() ? $classMetadata->getRepositoryClass() : BaseRepository::class;
            $this->repositories[$class] = new $repositoryClassName($classMetadata, $this, $class);
        }

        return $this->repositories[$class];
    }
218746
private function createDataMapper($entityClass)
    {
        /** @var DataMapperInterface $dataMapper */
        $dataMapperClass = isset($this->config['dataMapper']) ? $this->config['dataMapper'] : DoctrineDataMapper::class;

        $meta = $this->builder->getMeta($entityClass);

        if ($meta->storage['type'] == 'api') {
            $dataMapperClass = $meta->storage['handler'];
        }

        switch ($dataMapperClass) {
            case CsvDataMapper::class:
                $connectionClass = CsvDataGateway::class;

                break;

            default:
                $connectionClass = Connection::class;

                break;
        }

        $dataMapper = new $dataMapperClass(
            $this->getConnection($connectionClass),
            $entityClass,
            $meta->storage['table'],
            $this->entityRegistry
        );

        if ($dataMapper instanceof DispatcherAwareInterface) {
            $dataMapper->setDispatcher($this->getDispatcher());
        }

        return $dataMapper;
    }