public function getPairByUsersAction($idUser1, $idUser2)
 {
     $this->pairService->setManager($this->getDoctrine()->getManager());
     $pairs = $this->pairService->getPairByUsers($idUser1, $idUser2);
     $userService = new UserService();
     $userService->setManager($this->getDoctrine()->getManager());
     $user = $userService->getUser($idUser1);
     $user1 = $userService->getUser($idUser2);
     if ($user == null || $user1 == null) {
         return $this->util->setResponse(400, Literals::UserNotFound);
     } else {
         $dataToSend = json_encode(array('pair' => $pairs));
         return $this->util->setJsonResponse(200, $dataToSend);
     }
 }
Exemple #2
0
 public function savePair($params)
 {
     if (empty($this->getPairByUsers($params['user1'], $params['user2']))) {
         $userService = new UserService();
         $userService->setManager($this->em);
         $user1 = $userService->getUser($params['user1']);
         $user2 = $userService->getUser($params['user2']);
         $pair = new Pair();
         $pair->setUser1($user1);
         $pair->setUser2($user2);
         $pair->setGender($this->setPairGender($user1->getGender(), $user2->getGender()));
         $this->em->persist($pair);
         $this->em->flush();
         return array('result' => 'ok', 'message' => $pair);
     } else {
         return array('result' => 'fail', 'message' => Literals::PairDuplicate);
     }
 }
 private function setAnnotationSave($annotation, $params)
 {
     $annotation->setText(isset($params['text']) ? $params['text'] : '');
     $annotation->setStatus($this->statusService->getStatus('annotation', 'created'));
     $userService = new UserService();
     $userService->setManager($this->em);
     $user = $userService->getUser(isset($params['user']) ? $params['user'] : '');
     $annotation->setUser($user);
     return $annotation;
 }
 public function getInscriptionByUserAction($idUser)
 {
     $this->inscriptionService->setManager($this->getDoctrine()->getManager());
     $inscriptions = $this->inscriptionService->getInscriptionsByUser($idUser);
     $userService = new UserService();
     $userService->setManager($this->getDoctrine()->getManager());
     $user = $userService->getUser($idUser);
     if (!$user instanceof User) {
         return $this->util->setResponse(400, Literals::UserNotFound);
     } else {
         $dataToSend = json_encode(array('inscription' => $inscriptions));
         return $this->util->setJsonResponse(200, $dataToSend);
     }
 }