コード例 #1
0
 public function createRow()
 {
     $row = $this->stmt->fetch(PDO::FETCH_ASSOC);
     if (empty($row)) {
         return null;
     }
     $row['createdAt'] = date('Y-m-d, H:i:s', $row['createdAt']);
     $row['sex'] = $row['sex'] == 1 ? 'M' : 'F';
     $row['whereLearnt'] = $this->trans->trans(WhereLearntAbout::getItem($row['whereLearnt'])->getName(), [], 'edk');
     return $row;
 }
コード例 #2
0
ファイル: EdkParticipant.php プロジェクト: zyxist/cantiga
 /**
  * Validates the constraints for the participant registration.
  * 
  * @param ExecutionContextInterface $context
  */
 public function validate(ExecutionContextInterface $context)
 {
     $ok = true;
     if (!$this->terms1Accepted) {
         $context->buildViolation('TermsNotAcceptedErrorMsg')->atPath('terms1Accepted')->addViolation();
         $ok = false;
     }
     if (!$this->terms2Accepted) {
         $context->buildViolation('TermsNotAcceptedErrorMsg')->atPath('terms2Accepted')->addViolation();
         $ok = false;
     }
     if ($this->howManyTimes < 0) {
         $context->buildViolation('HowManyTimesWrongNumberErrorMsg')->atPath('howManyTimes')->addViolation();
         $ok = false;
     }
     if ($this->age < 1 || $this->age > 120) {
         $context->buildViolation('InvalidAgeErrorMsg')->atPath('age')->addViolation();
         $ok = false;
     }
     if (!empty($this->whereLearnt) && WhereLearntAbout::getItem($this->whereLearnt)->isCustom()) {
         if ('' == trim($this->whereLearntOther)) {
             $context->buildViolation('WhereLearntOtherErrorMsg')->atPath('whereLearntOther')->addViolation();
             $ok = false;
         }
     }
     if ($this->getRegistrationSettings()->hasCustomQuestion()) {
         if ('' == trim($this->customAnswer)) {
             $context->buildViolation('PleaseFillCustomAnswerErrorMsg')->atPath('customAnswer')->addViolation();
             $ok = false;
         }
     }
     $mpps = $this->getRegistrationSettings()->getMaxPeoplePerRecord();
     if ($mpps != 1) {
         if ($this->peopleNum > $mpps || $this->peopleNum < 1) {
             $context->buildViolation('RegisteredPeopleNumInvalidErrorMsg')->setParameter('%max%', $mpps)->atPath('peopleNum')->addViolation();
             $ok = false;
         }
     }
     if (!$this->getRegistrationSettings()->getAllowLimitExceed()) {
         if ($this->peopleNum + $this->getRegistrationSettings()->getParticipantNum() > $this->getRegistrationSettings()->getParticipantLimit()) {
             $context->buildViolation('NoMorePlacesErrorMsg')->addViolation();
             $ok = false;
         }
     }
     return $ok;
 }