/** * @param \ConsultBundle\Entity\Question $questionEntity * @param \ConsultBundle\Response\DetailQuestionResponseObject $questionResponseObject * * @return \ConsultBundle\Response\DetailQuestionResponseObject */ public static function mapDetailedQuestion(Question $questionEntity, DetailQuestionResponseObject $questionResponseObject = null) { if (empty($questionResponseObject)) { $questionResponseObject = new DetailQuestionResponseObject($questionEntity); } if (!empty($questionEntity)) { $replies = array(); foreach ($questionEntity->getDoctorQuestions() as $doctorQuestionEntity) { /** * @var DoctorQuestion $doctorQuestionEntity */ if (!empty($doctorQuestionEntity) || $doctorQuestionEntity->isSoftDeleted() || empty($doctorQuestionEntity->getDoctorReplies() || $doctorQuestionEntity->getDoctorReplies()->isSoftDeleted())) { $reply = new ReplyResponseObject(); self::mapDoctorQuestion($doctorQuestionEntity, $reply); $replies[] = $reply; } } $questionResponseObject->setReplies($replies); } return $questionResponseObject; }
/** * @param \ConsultBundle\Entity\Question $questionEntity * @param \ConsultBundle\Response\DetailQuestionResponseObject $question * * @throws \HttpException */ protected function fetchRepliesByQuestion(Question $questionEntity, DetailQuestionResponseObject $question, $practoAccountId = 0) { /** * @var DoctorQuestionRepository $er */ $er = $this->helper->getRepository(ConsultConstants::DOCTOR_QUESTION_ENTITY_NAME); $doctorQuestions = $er->findRepliesByQuestion($questionEntity, $practoAccountId); $replies = array(); foreach ($doctorQuestions as $doctorQuestion) { $reply = new ReplyResponseObject(); $reply->setAttributes($doctorQuestion); $reply->setDoctorFromAttributes($doctorQuestion); $replies[] = $reply; } $question->setReplies($replies); }