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
 private function checkIfAlertIsDeprecated(Alert $alert)
 {
     $nb = $this->alertRepository->countDeprecated($alert->getId());
     if ($nb > 1) {
         $alert->setStatus(Alert::STATUS_DEPRECATED);
         $alert->setFinishedAt(new \DateTime());
     }
     $this->em->persist($alert);
     $this->em->flush();
 }