Processes an entity instance to extract their identifier values.

@param object $entity The entity instance.

@return mixed A scalar value.

@throws ORMInvalidArgumentException
973503
public function getSingleIdentifierValue($entity)
    {
        $class     = $this->em->getClassMetadata(get_class($entity));
        $persister = $this->getEntityPersister($class->getClassName());

        if ($class->isIdentifierComposite()) {
            throw ORMInvalidArgumentException::invalidCompositeIdentifier();
        }

        $values = $this->isInIdentityMap($entity)
            ? $this->getEntityIdentifier($entity)
            : $persister->getIdentifier($entity);

        return $values[$class->identifier[0]] ?? null;
    }
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;
    }
899822
private function getContentFromEntity( $entity ) {
		switch ( $entity->getType() ) {
			case Item::ENTITY_TYPE:
				return new ItemContent( $entity );
			case Property::ENTITY_TYPE:
				return new PropertyContent( $entity );
			default:
				throw new RuntimeException( 'I cant get a content for this type of entity' );
		}
	}
249926
public function processParameterValue($value)
    {
        if (is_scalar($value)) {
            return $value;
        }

        if ($value instanceof Mapping\ClassMetadata) {
            return $value->discriminatorValue ?: $value->getClassName();
        }

        if ($value instanceof Collection) {
            $value = $value->toArray();
        }

        if (is_array($value)) {
            foreach ($value as $key => $paramValue) {
                $paramValue  = $this->processParameterValue($paramValue);
                $value[$key] = is_array($paramValue) ? reset($paramValue) : $paramValue;
            }

            return $value;
        }

        if (is_object($value) && $this->em->getMetadataFactory()->hasMetadataFor(StaticClassNameConverter::getClass($value))) {
            $value = $this->em->getUnitOfWork()->getSingleIdentifierValue($value);

            if ($value === null) {
                throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
            }
        }

        return $value;
    }
1261207
public function getServiceSpecification($entity)
    {
        if (!is_object($entity)) {
            if ((is_string($entity) && (!class_exists($entity))) // non-existent class
                    || (!is_string($entity)) // not an object or string
            ) {
                throw new Exception\InvalidArgumentException(sprintf(
                        '%s expects an object or valid class name; received "%s"',
                        __METHOD__,
                        var_export($entity, 1)
                ));
            }
        }
    
        $serviceSpec = new ArrayObject();
        $serviceSpec['operations'] = new ArrayObject();
    
        $reflection  = new ClassReflection($entity);
        $this->parseClassSpecifications($reflection, $serviceSpec);
        
        return $serviceSpec;
    }
443846
private function recursivCompleteEntity($entity)
    {
        switch (true) {
            case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Repertoire::class):

                return $this->metaRepository->findAssociationRepertoireByID($entity->getID());

                break;
            case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Category::class):

                return $this->metaRepository->findAssociationCategoryByID($entity->getID());

                break;
            case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Performancelevel::class):

                return $this->metaRepository->findAssociationPerformancelevelByID($entity->getID());

                break;
            case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Event\Type::class):

                return $this->metaRepository->findEventTypeByID($entity->getID());

                break;
            default:

                $classSchema = $this->reflectionService->getClassSchema(get_class($entity));

                foreach ($classSchema->getProperties() as $propertyName => $propertyDefinition) {
                    switch (true) {
                        case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):

                            $objectStorage = $entity->_getProperty($propertyName);
                            $newObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();

                            $objectStorage->rewind();

                            while ($objectStorage->valid()) {
                                $subEntity = $objectStorage->current();

                                if (!is_null($subEntity)) {
                                    $newSubEntity = $this->recursivCompleteEntity($subEntity);
                                    if ($newSubEntity) {
                                        $newObjectStorage->attach($newSubEntity);
                                    } else {
                                        $newObjectStorage->attach($subEntity);
                                    }
                                }

                                $objectStorage->next();
                            }

                            $entity->_setProperty($propertyName, $newObjectStorage);

                            break;
                        case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, true):

                            $subEntity = $entity->_getProperty($propertyName);

                            if (!is_null($subEntity)) {
                                $newSubEntity = $this->recursivCompleteEntity($subEntity);
                                $entity->_setProperty($propertyName, $newSubEntity);
                            }

                            break;
                    }
                }

                return $entity;

                break;
        }
    }
1120881
private function getRelatedEntityIdentifier($entity)
    {
        \assert('is_object($entity)');

        if ($entity instanceof \Doctrine\Common\Persistence\Proxy) {
            $entity->__load();
        }

        $relClass = \get_class($entity);

        $ManagerForClass = $this->registry->getManagerForClass($relClass);

        if (!$ManagerForClass) {
            throw new \InvalidArgumentException(sprintf('The getManagerForClass for entity of class "%s" was empty.', $relClass));
        }

        $relId = $ManagerForClass->getMetadataFactory()
            ->getMetadataFor($relClass)->getIdentifierValues($entity);

        asort($relId);

        if (!$relId) {
            throw new \InvalidArgumentException(sprintf('The identifier for entity of class "%s" was empty.', $relClass));
        }

        return [$relClass, json_encode($relId)];
    }
605952
public function processEntityMigration($entity)
    {
        if ($entity) {
            $reflection = ClassUtils::newReflectionObject($entity);
            if ($this->hasEncryptionEnabled($reflection) && !$entity->isEncrypted()) {
                $encryptionEnabledFields = $this->getEncryptionEnabledFields($reflection);

                // Normalize the field
                foreach ($encryptionEnabledFields as $field) {
                    $fieldNormalizer = $this->getFieldNormalizer($field, $reflection);
                    $value = $this->getFieldValue($entity, $field);
                    $processedValue = $fieldNormalizer->normalize($value);
                    $this->setFieldValue($entity, $field, $processedValue);
                }

                $entity->setMigrated(true);
            }
        }
    }
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;
    }
563897
public function transform($entity)
    {
        if (null === $entity || '' === $entity) {
            return array($this->arrayIdentifierName => '', $this->arrayLabelName => '');
        }

        if (!is_object($entity)) {
            throw new UnexpectedTypeException($entity, 'object');
        }

        //Here, do not put the result in the cache because we must check the value in
        //reverseTransform (by QueryBuilder)

        return array(
            $this->arrayIdentifierName => $this->accessor->getValue($entity, $this->identifier), //Identifier
            $this->arrayLabelName => $this->extractLabel($entity), //Label
        );
    }
466297
public function get($entity)
    {
        $key = $this->mapping['fieldname'];
        $valueMethod = 'get' . ucfirst($key);
        $value = $entity->$valueMethod();

        return $value;
    }
949892
public function getEntity($entity = null)
    {
        if ($entity === null) {
            $class = $this->class;
            $entity = new $class();
        }

        if ($entity instanceof Content && !$entity->getContenttype() && $ct = $this->getClassMetadata()->getBoltName()) {
            $contentType = $this->metadata->createContentType($ct);
            if ($contentType) {
                $entity->setContenttype($contentType);
            } else {
                $entity->setContenttype($ct);
            }
        }

        return $entity;
    }
1049834
public function findByEntityInstance($entity)
    {
        $businessEntity = null;
        $class = new \ReflectionClass($entity);
        while (!$businessEntity && $class && $class->name !== null) {
            $businessEntity = $this->findByEntityClassname($class->name);
            $class = $class->getParentClass();
        }

        return $businessEntity;
    }
1362252
public function extract($entity)
    {
        $metadata = $this->getMetadata();
        $collection = [];
        
        foreach ($metadata->getSQLNames() as $sqlName) {
            $propertyName = $metadata->getName($sqlName, Metadata::CAMILIZED);
            $propertyValue = $this->getReflection()->getProperty($propertyName)->getValue($entity);
            $propertyValue = $propertyValue !== null
                ? $metadata->toPlatform($metadata->getName($sqlName), $propertyValue) : null;
            $collection[$sqlName] = $propertyValue;
        }
        
        return $collection;
    }
1316052
public function transform($entity)
    {
        if (null === $entity || '' === $entity) {
            return null;
        }

        if (!is_object($entity)) {
            throw new UnexpectedTypeException($entity, 'object');
        }

        //Here, do not put the result in the cache because we must check the value in
        //reverseTransform (by QueryBuilder)

        return $this->accessor->getValue($entity, $this->identifier);
    }
1022971
public function get($entity)
    {
        $name = is_object($entity) ? get_class($entity) : $entity;
        if (!isset($this->_entities[$name])) {
            $this->_entities[$name] = new Descriptor(['entity' => $entity]);
        }
        return $this->_entities[$name];
    }
1116027
public function transform($entity)
    {
        if (null === $entity) {
            return '';
        }
        if (!is_subclass_of($entity, $this->entityClass)) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported entity "%s" into "%s" loader.',
                get_class($entity),
                __CLASS__
            ));
        }

        return $entity->getId();
    }