Ejemplo n.º 1
0
 /**
  * @param array   $requestParams   - parameters passed for creating new question object
  * @param integer $practoAccountId - practo account id
  * @param string  $profileToken    - profile token of the user
  * @return \ConsultBundle\Entity\Question
  * @throws \ConsultBundle\Manager\ValidationError
  */
 public function add($requestParams, $practoAccountId, $profileToken = null)
 {
     $question = new Question();
     $question->setSoftDeleted(false);
     $job = array();
     if (array_key_exists('city', $requestParams)) {
         $job['city'] = $requestParams['city'];
     }
     if (array_key_exists('speciality', $requestParams)) {
         $job['speciality'] = $requestParams['speciality'];
     }
     $userInfoParams = array();
     if (array_key_exists('user_info', $requestParams)) {
         $userInfoParams = $requestParams['user_info'];
         unset($requestParams['user_info']);
     }
     $userInfoParams['practo_account_id'] = $practoAccountId;
     $userEntry = $this->userManager->add($userInfoParams, $profileToken);
     $question->setUserInfo($userEntry);
     $params = $this->validator->validatePostArguments($requestParams);
     $this->updateFields($question, $params);
     $this->helper->persist($question, 'true');
     $job['question_id'] = $question->getId();
     $job['question'] = $question->getText();
     $job['subject'] = $question->getSubject();
     $this->queue->setQueueName(Queue::CLASSIFY)->sendMessage(json_encode($job));
     return $this->fetchDetailQuestionObject($question, $practoAccountId);
 }
Ejemplo n.º 2
0
 /**
  * @param \ConsultBundle\Entity\Question                       $questionEntity
  * @param                                                      $practoAccountId
  * @param \ConsultBundle\Response\DetailQuestionResponseObject $question
  *
  * @return \ConsultBundle\Response\DetailQuestionResponseObject|null
  * @throws \HttpException
  */
 protected function fetchDetailQuestionObject(Question $questionEntity, $practoAccountId, DetailQuestionResponseObject $question = null)
 {
     if (!empty($questionEntity) && empty($question)) {
         if (!$questionEntity->getUserInfo()->isIsRelative()) {
             $this->userProfileUtil->retrieveUserProfileNew($questionEntity->getUserInfo());
         }
         $question = new DetailQuestionResponseObject($questionEntity, $practoAccountId);
     }
     $this->fetchRepliesByQuestion($questionEntity, $question, $practoAccountId);
     $bookmarkCount = $this->helper->getRepository(ConsultConstants::QUESTION_ENTITY_NAME)->getBookmarkCountForAQuestion($questionEntity);
     $question->setBookmarkCount($bookmarkCount);
     $er = $this->helper->getRepository(ConsultConstants::QUESTION_BOOKMARK_ENTITY_NAME);
     //Set comments
     /**
      * @var QuestionCommentRepository $ecr
      */
     $ecr = $this->helper->getRepository(ConsultConstants::QUESTION_COMMENT_ENTITY_NAME);
     $questionCommentList = $ecr->getComments($questionEntity, 10, 0, $practoAccountId);
     $question->setComments($questionCommentList);
     if (!empty($practoAccountId)) {
         $bookmark = $er->findOneBy(array("practoAccountId" => $practoAccountId, "question" => $questionEntity, "softDeleted" => 0));
         if (!empty($bookmark)) {
             $question->setIsBookmarked(true);
         }
     }
     return $question;
 }
Ejemplo n.º 3
0
 /**
  * @param \ConsultBundle\Entity\Question $question
  */
 public function loadUserDetailInQuestion(Question $question)
 {
     $userInfo = $question->getUserInfo();
     if (!$userInfo->isIsRelative()) {
         $userInfo = $this->retrieveUserProfileNew($userInfo);
         $question->setUserInfo($userInfo);
     }
 }
Ejemplo n.º 4
0
 /**
  * @param Question $question        - question object
  * @param integer  $practoAccountId - User's id
  * @return bool
  */
 public function checkUniqueness($question, $practoAccountId)
 {
     foreach ($question->getBookmarks() as $bookmark) {
         if ($bookmark->getPractoAccountId() == $practoAccountId) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Get QuestionId
  *
  * @return integer
  */
 public function getQuestionId()
 {
     if ($this->question) {
         return $this->question->getId();
     }
     return null;
 }
Ejemplo n.º 6
0
 private static function mapBasicQuestion(Question $questionEntity, BasicQuestionResponseObject $question)
 {
     $question->setId($questionEntity->getId());
     $question->setSpeciality($questionEntity->getSpeciality());
     $question->setViewCount($questionEntity->getViewCount());
     $question->setShareCount($questionEntity->getSpeciality());
     $question->setSubject($questionEntity->getSubject());
     $question->setText($questionEntity->getText());
     $question->setModifiedAt($questionEntity->getModifiedAt());
     $question->setCreatedAt($questionEntity->getCreatedAt());
     $question->setCreatedAt($questionEntity->getCreatedAt());
 }