Beispiel #1
0
 public function checkParticipantsIdFormat($attribute)
 {
     $participants = $this->{$attribute};
     $errorMessage = "{attribute} имеет неверный формат.";
     $participantsValue = [];
     if (is_array($participants)) {
         $mongoIdValidator = new MongoIdValidator();
         foreach ($participants as $participant) {
             if ($mongoIdValidator->validate($participant)) {
                 $participantsValue[] = new \MongoId($participant);
             } else {
                 $this->addError($attribute, $errorMessage);
                 return;
             }
         }
         $this->{$attribute} = $participantsValue;
         return;
     }
     $this->addError($attribute, $errorMessage);
 }