/** * @param int $id * * @ApiDoc( * description="GooglePlace search", * statusCodes={200="Address GooglePlace"}, * section="Google Place") * @Route("/api/google-places/place-results/{id}") * @throws BadRequestException * @Method({"GET"}) * @Cache(maxage="+1 week", public=true) * @return View */ public function getAction($id) { $place = $this->googlePlaceClient->detail($id); $address = new Address(); $address->setCity($place->getCity()); $address->setLat($place->getLatitude()); $address->setLng($place->getLongitude()); $geoname = $this->geonameRepository->getOneByAddress($address); $place->setGeoname($geoname); return $this->view(array('placeResult' => $place)); }
/** * @param FullPlaceResult $place * @return Address * * @throws UnresolvedGeonameException */ public function createFromFullPlaceResult(FullPlaceResult $place) { $address = new Address(); $address->setCity($place->getCity()); $address->setLat($place->getLatitude()); $address->setLng($place->getLongitude()); $address->setCountry($place->getCountry()); $address->setCountryCode($place->getCountryCode()); $address->setFormattedAddress($place->getFormattedAddress()); $address->setRegion($place->getRegion()); $address->setRegionCode($place->getRegionCode()); $address->setCounty($place->getCounty()); $address->setCountyCode($place->getCountyCode()); $address->setCity($place->getCity()); $address->setPostalCode($place->getPostalCode()); $address->setStreetName($place->getStreetName()); $address->setStreetNumber($place->getStreetNumber()); $geoname = $this->geonameRepository->getOneByAddress($address); $address->setGeoname($geoname); return $address; }