コード例 #1
0
 public function geolocate(Location $location)
 {
     //this will only work for western europe because the format may be different for other countries... big switch
     //may be needed...
     $address = $location->getStreetNumber() . '+' . $location->getStreet() . '+' . $location->getPc() . '+' . $location->getTown() . '+' . $location->getCountry();
     $address = urlencode($address);
     $query = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=' . $this->ch->getParameter('google_geocoding_key');
     return $this->cm->exec($query);
 }
コード例 #2
0
ファイル: Persister.php プロジェクト: claroline/distribution
 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;
 }
コード例 #3
0
 /**
  * @EXT\Route(
  *     "/api/cursus/location/{location}/delete",
  *     name="api_delete_cursus_location",
  *     options = {"expose"=true}
  * )
  * @EXT\ParamConverter("user", converter="current_user")
  *
  * Deletes session event
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function deleteLocationAction(Location $location)
 {
     if ($location->getType() !== Location::TYPE_TRAINING) {
         throw new AccessDeniedException();
     }
     $serializedLocation = $this->serializer->serialize($location, 'json', SerializationContext::create()->setGroups(['api_user_min']));
     $this->locationManager->delete($location);
     return new JsonResponse($serializedLocation, 200);
 }