Skip to content

Commit

Permalink
Merge pull request #116 from yaBliznyk/patch-1
Browse files Browse the repository at this point in the history
Update EMongoIdValidator.php
  • Loading branch information
Sammaye committed Sep 9, 2013
2 parents ff965f7 + c999701 commit 2b5eb8e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion validators/EMongoIdValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ protected function validateAttribute($object,$attribute){
$value=$object->$attribute;
if($this->allowEmpty && $this->isEmpty($value))
return;
if(is_array($value)) {
foreach ($value as $key=>$attr) {
$value[$key] = $attr instanceof MongoId ? $attr : new MongoId($attr);
}
$object->$attribute = $value;
} else
$object->$attribute=$object->$attribute instanceof MongoId ? $object->$attribute : new MongoId($object->$attribute);
}
}
}

0 comments on commit 2b5eb8e

Please sign in to comment.