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(); }