createForEntity example

 null;

        $insert = new InsertCommand(
            $this->versionCommitDefinition,
            [
                'id' => $commitId,
                'user_id' => $userId,
                'version_id' => Uuid::fromHexToBytes($versionId),
                'created_at' => $date,
            ],
            ['id' => $commitId],
            EntityExistence::createForEntity(
                $this->versionCommitDefinition->getEntityName(),
                ['id' => Uuid::fromBytesToHex($commitId)],
            ),
            ''
        );

        $commands = [$insert];

        foreach ($writtenEvents as $items) {
            if (\count($items) === 0) {
                continue;
            }
/** @var Field&StorageAware $pkField */
        foreach ($definition->getPrimaryKeys() as $pkField) {
            $parameters->getContext()->set(
                $parameters->getDefinition()->getEntityName(),
                $pkField->getPropertyName(),
                $pkField->getSerializer()->decode($pkField$pkData[$pkField->getStorageName()]),
            );
        }

        if ($definition instanceof MappingEntityDefinition) {
            // gateway will execute always a replace into             $existence = EntityExistence::createForEntity($definition->getEntityName()[]);
        } else {
            $existence = $this->entityExistenceGateway->getExistence($definition$pkData$rawData$parameters->getCommandQueue());
        }

        $stack = $this->createDataStack($existence$definition$parameters$rawData);

        $mainFields = $this->getMainFields($fields);

        // without child association         $data = $this->map($mainFields$stack$existence$parameters);

        
$tupleCount = 0;

            foreach ($pks as $pk) {
                $newIds = [];
                foreach ($pkFields as $field) {
                    $id = $pk[$field->getPropertyName()] ?? null;
                    if ($id === null) {
                        continue 2;
                    }
                    $newIds[] = $field->getSerializer()->encode(
                        $field,
                        EntityExistence::createForEntity($definition->getEntityName()[$field->getPropertyName() => $id]),
                        new KeyValuePair($field->getPropertyName()$id, true),
                        $parameters,
                    )->current();
                }

                foreach ($newIds as $newId) {
                    $params[] = $newId;
                }

                ++$tupleCount;
            }

            

            foreach ($primaryKey as $key => $value) {
                /** * Primary key fields are always storage aware. * * @var Field&StorageAware $field */
                $field = $definition->getFields()->get($key);

                $mappedBytes[$field->getStorageName()] = $field->getSerializer()->encode(
                    $field,
                    EntityExistence::createForEntity($definition->getEntityName()[$key => $value]),
                    new KeyValuePair($key$value, true),
                    $parameters,
                )->current();
            }

            $existence = $this->gateway->getExistence($definition$mappedBytes[]$commandQueue);

            if ($existence->exists()) {
                $commandQueue->add($definitionnew DeleteCommand($definition$mappedBytes$existence));

                continue;
            }
Home | Imprint | This part of the site doesn't use cookies.