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);
 }