Exemplo n.º 1
0
 public function __construct(Alert $alert)
 {
     $this->id = $alert->getId();
     $this->positionLong = $alert->getPositionLong();
     $this->positionLat = $alert->getPositionLat();
     $this->positionCity = $alert->getPositionCity();
     $this->positionDep = $alert->getPositionDep();
     $this->positionCountry = $alert->getPositionCountry();
     $this->category = $alert->getCategory();
     $this->status = $alert->getStatus();
     $this->createdAt = $alert->getCreatedAt();
     $this->finishedAt = $alert->getFinishedAt();
     $this->description = $alert->getDescription();
     $user = new UserDTO($alert->getUserCreator());
     $this->userCreator = $user;
     $nbDeprecated = 0;
     foreach ($alert->getUserHelpAlerts() as $userHelpAlert) {
         $this->userHelpAlerts[] = new UserHelpAlertDTO($userHelpAlert);
         if ($userHelpAlert->isDeprecated()) {
             $nbDeprecated++;
         }
     }
     $this->nbAlertsDeprecated = $nbDeprecated;
 }
Exemplo n.º 2
0
 /**
  * @param Alert $alert
  *
  * @return AlertDTO
  */
 public function updateAlert(Alert $alert)
 {
     $infos = Geocoder::getLocation($alert->getPositionLat(), $alert->getPositionLong());
     $city = Geocoder::getCityFromAddress($infos);
     $department = Geocoder::getDepartmentFromAddress($infos);
     $country = Geocoder::getCountryFromAddress($infos);
     $alert->setPositionCity($city);
     $alert->setPositionDep($department);
     $alert->setPositionCountry($country);
     $this->em->persist($alert);
     $this->em->flush();
     return new AlertDTO($alert);
 }