public function location($name) { $location = new Location(); $location->setName($name); $location->setStreet($name); $location->setStreetNumber($name); $location->setBoxNumber($name); $location->setPc($name); $location->setTown($name); $location->setCountry($name); $location->setLatitude(123); $location->setLongitude(123); $this->om->persist($location); return $location; }
/** * @EXT\Route( * "/api/cursus/location/{location}/edit", * name="api_put_cursus_location_edition", * options = {"expose"=true} * ) * @EXT\ParamConverter("user", converter="current_user") */ public function putLocationEditAction(Location $location) { if ($location->getType() !== Location::TYPE_TRAINING) { throw new AccessDeniedException(); } $locationDatas = $this->request->request->get('locationDatas', false); $location->setName($locationDatas['name']); $location->setStreet($locationDatas['street']); $location->setStreetNumber($locationDatas['streetNumber']); $location->setBoxNumber($locationDatas['boxNumber']); $location->setPc($locationDatas['pc']); $location->setTown($locationDatas['town']); $location->setCountry($locationDatas['country']); $location->setPhone($locationDatas['phone']); $this->locationManager->edit($location); $serializedLocation = $this->serializer->serialize($location, 'json', SerializationContext::create()->setGroups(['api_user_min'])); return new JsonResponse($serializedLocation, 200); }