linking demandes

This commit is contained in:
Tykayn 2025-07-16 23:01:13 +02:00 committed by tykayn
parent 0aa050b38b
commit 7f79ec3a9f
6 changed files with 190 additions and 10 deletions

View file

@ -151,6 +151,20 @@ class PublicController extends AbstractController
$demande->setOsmId((int)$data['osmId']);
}
// Check if a Place exists with the same OSM ID and type
if ($demande->getOsmId() && $demande->getOsmObjectType()) {
$existingPlace = $this->entityManager->getRepository(Place::class)->findOneBy([
'osm_kind' => $demande->getOsmObjectType(),
'osmId' => $demande->getOsmId()
]);
if ($existingPlace) {
// Link the Place UUID to the Demande
$demande->setPlaceUuid($existingPlace->getUuidForUrl());
$demande->setPlace($existingPlace);
}
}
$this->entityManager->persist($demande);
$this->entityManager->flush();