generated from Nodarx/template
fix: entityExtant()
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -596,11 +596,17 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
$allUids = $this->remoteService->entityList((string) $collection);
|
||||
$uidSet = array_flip($allUids); // int[] → [uid => index]
|
||||
$extant = [];
|
||||
// only positive integers are valid UIDs; anything else cannot exist
|
||||
$uids = array_values(array_filter(
|
||||
array_map(static fn (string|int $id): int => (int) $id, $identifiers),
|
||||
static fn (int $uid): bool => $uid > 0,
|
||||
));
|
||||
|
||||
$existing = array_flip($this->remoteService->entityExtant((string) $collection, ...$uids));
|
||||
|
||||
$extant = [];
|
||||
foreach ($identifiers as $id) {
|
||||
$extant[$id] = isset($uidSet[(int) $id]);
|
||||
$extant[$id] = isset($existing[(int) $id]) && (string) (int) $id === (string) $id;
|
||||
}
|
||||
return $extant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user