recator: entity move and delete
Some checks failed
Build Test / test (pull_request) Successful in 39s
JS Unit Tests / test (pull_request) Failing after 38s
PHP Unit Tests / test (pull_request) Successful in 1m2s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-07 23:53:21 -04:00
parent c33a74003d
commit c1dbcc9a7d
3 changed files with 67 additions and 93 deletions

View File

@@ -1033,13 +1033,7 @@ class Manager {
}
if ($service === null) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => 'serviceNotFound',
];
}
continue;
throw new InvalidArgumentException("Service not found: $providerName/$serviceName");
}
// Temporarily disabled check until all methods are properly implemented from ServiceEntityMutableInterface
@@ -1065,34 +1059,7 @@ class Manager {
}
*/
try {
$operationResult = $service->entityDelete(...$serviceSources->all());
foreach ($serviceSources as $identifier) {
$sourceIdentifier = (string)$identifier;
$entityIdentifier = $identifier->entity();
$result = $operationResult[$entityIdentifier] ?? null;
if ($result === true) {
$operationOutcome[$sourceIdentifier] = [
'success' => true,
];
continue;
}
$operationOutcome[$sourceIdentifier] = [
'success' => false,
'error' => is_string($result) && $result !== '' ? $result : 'unknownError',
];
}
} catch (\Throwable $e) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => $e->getMessage(),
];
}
}
return $service->entityDelete(...$serviceSources->all());
}
}
@@ -1115,31 +1082,7 @@ class Manager {
$destinationSources = $sources->byProvider($targetService->provider())->byService((string)$targetService->identifier());
if (!$destinationSources->isEmpty()) {
$operationResult = $targetService->entityMove($target, ...$destinationSources->all());
foreach ($destinationSources as $identifier) {
$sourceIdentifier = (string)$identifier;
$entityIdentifier = $identifier->entity();
$result = $operationResult[$entityIdentifier] ?? null;
if ($result === true) {
$operationOutcome[$sourceIdentifier] = [
'success' => true,
'identifier' => (string)new EntityIdentifier(
$target->provider(),
$target->service(),
$target->collection(),
$entityIdentifier,
),
];
continue;
}
$operationOutcome[$sourceIdentifier] = [
'success' => false,
'error' => is_string($result) && $result !== '' ? $result : 'unknownError',
];
}
$operationOutcome = $targetService->entityMove($target, ...$destinationSources->all());
}
// TODO: Handle moving entities across different services/providers by fetching each entity and re-creating it in the target collection,