Populates the entity identifier of an entity.

@param object $xmlEntity
@param mixed $id
@todo Rename to assignIdentifier()
764395
public function setIdentifierValue($xmlEntity, array $id)
    {
        foreach ($id as $idField => $idValue) {
            $this->reflFields[$idField]->setValue($xmlEntity, $idValue);
        }
    }
171042
public function setID($identity)
    {
        $idAttribute = $this->idAttribute;
        return (is_string($idAttribute) && !empty($idAttribute)) ? $this->$idAttribute = $identity : null;
    }
731486
protected function _instantiateEntity($identifier, $data)
    {
        //since the identifier doesn't have an
        //application set, it gets the application of the parent
        //repository
        $identifier = AnService::getIdentifier($identifier);
        $identifier->application = $this->getIdentifier()->application;

        return clone AnDomain::getRepository($identifier)->getClone();
    }
717560
protected void store(Object id, Object entity)
    {
        store(id, entity, Boolean.TRUE);
    }
755739
@Override
    protected List<Object> populateEntities(EntityMetadata m, Client client)
    {
        return onQuery(m, client);
    }
311801
private static function deserializeOpenIdConnectDiscoveryDocument($xmlElement)
    {
        if (!isset($xmlElement->OpenIdDiscoveryUri)) {
            throw new \RuntimeException(
                "The OpenIdConnectDiscoveryDocument must contains a 'OpenIdDiscoveryUri' element"
            );
        }

        $result = new OpenIdConnectDiscoveryDocument();
        $result->setOpenIdDiscoveryUri((string) $xmlElement->OpenIdDiscoveryUri);

        return $result;
    }
288584
public function scheduleForDirtyCheck($xmlEntity)
    {
        $rootClassName = $this->xem->getClassMetadata(get_class($xmlEntity))->rootXmlEntityName;
        $this->scheduledForDirtyCheck[$rootClassName][spl_object_hash($xmlEntity)] = $xmlEntity;
    }
1155723
@Override
    protected List recursivelyPopulateEntities(EntityMetadata m, Client client)
    {
        List<EnhanceEntity> ls = populateEntities(m, client);
        return setRelationEntities(ls, client, m);
    }
1035540
public void assignID(XAttributable element, XID id) {
		if (id != null) {
			XAttributeID attr = (XAttributeID) ATTR_ID.clone();
			attr.setValue(id);
			element.getAttributes().put(KEY_ID, attr);
		}
	}
1202089
protected function getEntityForAttribut($entity, $xmlEntry, $attributName, $stackEntity)
    {
        switch ($attributName) {
      case 'associationid':

        $association = $entity->getAssociation();

        if (!$association) {
            $association = new Association();
            $entity->setAssociation($association);
        }

        return $association;
        break;
            default:
                return $entity;
                break;
        }
    }
853424
private function initFieldDescriptors($entityName, $id)
    {
        $mediaEntityName = $this->getParameter('sulu.model.media.class');

        $entityJoin = new DoctrineJoinDescriptor(
            $mediaEntityName,
            $entityName . '.medias',
            $entityName . '.id = ' . $id,
            DoctrineJoinDescriptor::JOIN_METHOD_INNER
        );

        $this->fieldDescriptors = [];

        $this->fieldDescriptors['entity'] = new DoctrineFieldDescriptor(
            'id',
            'entity',
            $entityName,
            null,
            [],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_NO
        );

        $this->fieldDescriptors['id'] = new DoctrineFieldDescriptor(
            'id',
            'id',
            $mediaEntityName,
            'public.id',
            [
                $mediaEntityName => $entityJoin,
            ],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_NO
        );

        $this->fieldDescriptors['thumbnails'] = new DoctrineFieldDescriptor(
            'id',
            'thumbnails',
            $mediaEntityName,
            'media.media.thumbnails',
            [
                $mediaEntityName => $entityJoin,
            ],
            FieldDescriptorInterface::VISIBILITY_YES,
            FieldDescriptorInterface::SEARCHABILITY_NEVER,
            'thumbnails',
            false
        );

        $this->fieldDescriptors['name'] = new DoctrineFieldDescriptor(
            'name',
            'name',
            self::$fileVersionEntityName,
            'public.name',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
            ]
        );
        $this->fieldDescriptors['size'] = new DoctrineFieldDescriptor(
            'size',
            'size',
            self::$fileVersionEntityName,
            'media.media.size',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
            ],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_NEVER,
            'bytes'
        );

        $this->fieldDescriptors['changed'] = new DoctrineFieldDescriptor(
            'changed',
            'changed',
            self::$fileVersionEntityName,
            'public.changed',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
            ],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_NEVER,
            'date'
        );

        $this->fieldDescriptors['created'] = new DoctrineFieldDescriptor(
            'created',
            'created',
            self::$fileVersionEntityName,
            'public.created',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
            ],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_NEVER,
            'date'
        );

        $this->fieldDescriptors['title'] = new DoctrineFieldDescriptor(
            'title',
            'title',
            self::$fileVersionMetaEntityName,
            'public.title',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
                self::$fileVersionMetaEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionMetaEntityName,
                    self::$fileVersionEntityName . '.meta'
                ),
            ],
            FieldDescriptorInterface::VISIBILITY_NO,
            FieldDescriptorInterface::SEARCHABILITY_YES,
            'title'
        );

        $this->fieldDescriptors['description'] = new DoctrineFieldDescriptor(
            'description',
            'description',
            self::$fileVersionMetaEntityName,
            'media.media.description',
            [
                $mediaEntityName => $entityJoin,
                self::$fileEntityName => new DoctrineJoinDescriptor(
                    self::$fileEntityName,
                    $mediaEntityName . '.files'
                ),
                self::$fileVersionEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionEntityName,
                    self::$fileEntityName . '.fileVersions',
                    self::$fileVersionEntityName . '.version = ' . self::$fileEntityName . '.version'
                ),
                self::$fileVersionMetaEntityName => new DoctrineJoinDescriptor(
                    self::$fileVersionMetaEntityName,
                    self::$fileVersionEntityName . '.meta'
                ),
            ],
            FieldDescriptorInterface::VISIBILITY_YES,
            FieldDescriptorInterface::SEARCHABILITY_YES
        );
    }
909926
public function validateIdentifier($id)
    {
        $printed = print_r($id, true);
        if (count($this->keys) > 1 && !is_array($id)) {
            throw new \RuntimeException("Entity $this->name has a composed key, finding by id requires an array, given: $printed");
        }
        if (count($this->keys) !== count($id)) {
            $keys = print_r($this->keys, true);
            throw new \RuntimeException("Entity $this->name requires the following keys: $keys, given: $printed");
        }
    }
1050495
protected function mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity)
    {
        $classSchema = $this->reflectionService->getClassSchema(get_class($entity));

        if ($classSchema->hasProperty($property)) {
            $propertyDefinition = $classSchema->getProperty($property);

            switch (true) {
                    case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):

                        foreach ($xmlEntry->children() as $xmlChildEntry) {
                            $name = $xmlChildEntry->getName();
                            $childEntity = new $propertyDefinition['elementType']();
                            $entityForTagName = $this->getEntityForTagName($childEntity, $xmlEntry, $name, $stackEntity);

                            if (is_a($entityForTagName, $propertyDefinition['elementType'], true)) {
                                $entity->_getProperty($property)->attach($childEntity);
                            }

                            $this->mapXMLElementToEntity($xmlChildEntry, $entityForTagName, $stackEntity);
                        }

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

                        $subEntity = $entity->_getProperty($property);
                        if (!$subEntity) {
                            $subEntity = new $propertyDefinition['type']();
                            $entity->_setProperty($property, $subEntity);
                        }

                        $this->mapXMLElementToEntity($xmlEntry, $subEntity, $stackEntity);
                        break;
                    case is_a($propertyDefinition['type'], \DateTime::class, true):

                        if (!empty($value)) {
                            $dateTime = new \DateTime($value);
                            $entity->_setProperty($property, $dateTime);
                        }

                        break;

                    default:
                        $entity->_setProperty($property, $value);
            }

            return true;
        } else {
            return false;
        }
    }
604181
public function setIdentifierValue(object $document, $id) : void
    {
        $id = $this->getPHPIdentifierValue($id);
        $this->reflFields[$this->identifier]->setValue($document, $id);
    }
871613
private Entity toEntity(EntityType entityType, Entity emxEntity) {
    Entity entity = entityManager.create(entityType, POPULATE);
    for (Attribute attr : entityType.getAtomicAttributes()) {
      if (attr.getExpression() == null && !attr.isMappedBy()) {
        String attrName = attr.getName();
        Object emxValue = emxEntity.get(attrName);

        AttributeType attrType = attr.getDataType();
        switch (attrType) {
          case BOOL:
          case DATE:
          case DATE_TIME:
          case DECIMAL:
          case EMAIL:
          case ENUM:
          case HTML:
          case HYPERLINK:
          case INT:
          case LONG:
          case SCRIPT:
          case STRING:
          case TEXT:
            Object value = emxValue != null ? DataConverter.convert(emxValue, attr) : null;
            if ((!attr.isAuto() || value != null) && (!attr.hasDefaultValue() || value != null)) {
              entity.set(attrName, value);
            }
            break;
          case CATEGORICAL:
          case FILE:
          case XREF:
            // DataConverter.convert performs no conversion for reference types
            Entity refEntity = toRefEntity(attr, emxValue);

            // do not set generated auto refEntities to null
            if ((!attr.isAuto() || refEntity != null)
                && (!attr.hasDefaultValue() || refEntity != null)) {
              entity.set(attrName, refEntity);
            }
            break;
          case CATEGORICAL_MREF:
          case MREF:
            // DataConverter.convert performs no conversion for reference types
            List<Entity> refEntities = toRefEntities(attr, emxValue);

            // do not set generated auto refEntities to null
            if (!refEntities.isEmpty()) {
              entity.set(attrName, refEntities);
            }
            break;
          case COMPOUND:
            throw new IllegalAttributeTypeException(attrType);
          default:
            throw new UnexpectedEnumException(attrType);
        }
      }
    }
    return entity;
  }
1122199
private function createEntityID(string $id): EntityID
    {
        return new EntityID($this->entityManager, $this->className, $id);
    }
335918
public function persist($xmlEntity)
    {
        $class = $this->xem->getClassMetadata(get_class($xmlEntity));

        if ($class->isMappedSuperclass) {
            throw OXMException::cannotPersistMappedSuperclass($class->name);
        }
        if (!$class->isRoot) {
            throw OXMException::canOnlyPersistRootClasses($class->name);
        }
        $visited = array();
        $this->doPersist($xmlEntity, $visited);
    }