コード例 #1
0
 public function validate($value, Constraint $constraint)
 {
     $today = new \DateTime();
     if ($value > $today) {
         $this->context->addViolation($constraint->message1);
     }
     if ($value <= $constraint->getColonie()->getDateColonie()) {
         $this->context->addViolation($constraint->message2);
     }
     if (!$constraint->getColonie()->getVisites()->isEmpty()) {
         if ($value <= $constraint->getColonie()->getVisites()->last()->getDate()) {
             $this->context->addViolation($constraint->message3);
         }
     }
     if (!$constraint->getColonie()->getRemerages()->isEmpty()) {
         if ($value <= $constraint->getColonie()->getRemerages()->last()->getDate()) {
             $this->context->addViolation($constraint->message4);
         }
     }
     if (!$constraint->getColonie()->getTranshumances()->isEmpty()) {
         if ($value <= $constraint->getColonie()->getTranshumances()->last()->getDate()) {
             $this->context->addViolation($constraint->message5);
         }
     }
 }