$payload['id'
] =
$existing->
getId();
$existingCmsBlocks->
remove($existing->
getId());
} $upserts[] =
$payload;
} if (!
empty($upserts)) { $this->cmsBlockRepository->
upsert($upserts,
$context);
} $this->
deleteOldCmsBlocks($existingCmsBlocks,
$context);
} private function deleteOldCmsBlocks(AppCmsBlockCollection
$toBeRemoved, Context
$context): void
{ /** @var array<string> $ids */
$ids =
$toBeRemoved->
getIds();
if (!
empty($ids)) { $ids =
array_map(static fn (string
$id): array =>
['id' =>
$id],
array_values($ids));
$this->cmsBlockRepository->
delete($ids,
$context);
}