recator: entity move and delete
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user