getEntityExistence example

$operation = EntityWriteResult::OPERATION_INSERT;
                } elseif ($command instanceof DeleteCommand) {
                    $operation = EntityWriteResult::OPERATION_DELETE;
                }

                $payload = $this->getCommandPayload($command);
                $writeResults[$uniqueId] = new EntityWriteResult(
                    $primaryKey,
                    $payload,
                    $command->getDefinition()->getEntityName(),
                    $operation,
                    $command->getEntityExistence(),
                    $command instanceof ChangeSetAware ? $command->getChangeSet() : null
                );
            }

            /* * Updates for entities with attributes are split into two commands: an UpdateCommand and a JsonUpdateCommand. * We need to merge the payloads here. */
            foreach ($jsonUpdateCommands as $uniqueId => $command) {
                $payload = [];
                if (isset($writeResults[$uniqueId])) {
                    
return $overallResults;
        }

        if (!$result && $this->failedWriteCommands) {
            foreach ($this->failedWriteCommands as $writeCommand) {
                if (!$writeCommand instanceof WriteCommand) {
                    continue;
                }

                $entityName = $writeCommand->getDefinition()->getEntityName();
                $entityResult = $overallResults[$entityName] ?? $defaultTemplate;
                $operation = $writeCommand->getEntityExistence()->exists()
                    ? EntityWriteResult::OPERATION_UPDATE
                    : EntityWriteResult::OPERATION_INSERT;
                $type = $writeCommand->isFailed() ? 'Error' : 'Skip';
                ++$entityResult[sprintf('%s%s', $operation$type)];
                $overallResults[$entityName] = $entityResult;
            }

            return $overallResults;
        }

        if (!$result || !$result->getEvents()) {
            
Home | Imprint | This part of the site doesn't use cookies.