Ejemplo n.º 1
0
 /**
  * Adds / updates a comment on an answer to the given question.
  * @param string $databaseName
  * @param string $questionId
  * @param string $answerId
  * @param CommentModel $comment
  */
 public static function writeComment($databaseName, $questionId, $answerId, $comment)
 {
     $id = $comment->id->asString();
     if (empty($id)) {
         $id = $comment->id->id = QuestionModelMongoMapper::makeId();
     }
     $mapper = QuestionModelMongoMapper::connect($databaseName);
     $mapper->write($comment, $id, MongoMapper::ID_IN_KEY, $questionId, "answers.{$answerId}.comments");
     return $id;
 }