Generate coordinates when offer added

This commit is contained in:
Jannis Portmann 2022-01-12 14:42:02 +01:00
parent 3a525f397c
commit c6eadf742c
3 changed files with 64 additions and 2 deletions

View file

@ -38,7 +38,7 @@ class OfferController extends AbstractController
}
#[Route('/new', name: 'new_offer')]
public function newOffer(Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response
public function newOffer(Request $request, PlzToCoordinate $plzconverter, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response
{
$offer = new Offering();
$form = $this->createForm(OfferingFormType::class, $offer);
@ -50,6 +50,11 @@ class OfferController extends AbstractController
$offer->setByUser($user);
$offer->setCreatedAt(new \DateTime());
$coordinate = $plzconverter->convertPlzToCoordinate($form['zipCode']->getData());
if ($coordinate != null) {
$offer->setCoordinate($coordinate);
}
if ($photo = $form['photo']->getData()) {
$offerPhotoHelper->uploadOfferPhoto($photoDir, $photo, $offer);
}