| @@ 83-90 (lines=8) @@ | ||
| 80 | array('object_to_populate' => $survey) |
|
| 81 | ); |
|
| 82 | $errors = $this->get('validator')->validate($survey); |
|
| 83 | if ($errors->count()) { |
|
| 84 | $outErrors = []; |
|
| 85 | /** @var ConstraintViolation $error */ |
|
| 86 | foreach ($errors as $error) { |
|
| 87 | $outErrors[$error->getPropertyPath()] = $error->getMessage(); |
|
| 88 | } |
|
| 89 | throw new JsonHttpException(400, 'Bad Request', $outErrors); |
|
| 90 | } |
|
| 91 | $em->persist($survey); |
|
| 92 | $em->flush(); |
|
| 93 | ||
| @@ 110-119 (lines=10) @@ | ||
| 107 | AbstractNormalizer::OBJECT_TO_POPULATE => $user |
|
| 108 | ]); |
|
| 109 | $errors = $this->get('validator')->validate($user, null, ['edit']); |
|
| 110 | if ($errors->count()) { |
|
| 111 | $outErrors = []; |
|
| 112 | ||
| 113 | /** @var ConstraintViolation $error */ |
|
| 114 | foreach ($errors as $error) { |
|
| 115 | $outErrors[$error->getPropertyPath()] = $error->getMessage(); |
|
| 116 | } |
|
| 117 | ||
| 118 | throw new JsonHttpException(400, 'This value is already used.', $outErrors); |
|
| 119 | } |
|
| 120 | $this->getDoctrine()->getManager()->flush(); |
|
| 121 | ||
| 122 | return $this->json(['user' => $this->getUser()], 200, [], [AbstractNormalizer::GROUPS => ['Short']]); |
|
| @@ 74-81 (lines=8) @@ | ||
| 71 | } |
|
| 72 | ||
| 73 | $errors = $this->get('validator')->validate($formRequest); |
|
| 74 | if ($errors->count()) { |
|
| 75 | $outErrors = []; |
|
| 76 | /** @var ConstraintViolation $error */ |
|
| 77 | foreach ($errors as $error) { |
|
| 78 | $outErrors[$error->getPropertyPath()] = $error->getMessage(); |
|
| 79 | } |
|
| 80 | throw new JsonHttpException(400, 'Bad Request', $outErrors); |
|
| 81 | } |
|
| 82 | $em->persist($formRequest); |
|
| 83 | $em->flush(); |
|
| 84 | ||