| @@ 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 | ||
| @@ 36-45 (lines=10) @@ | ||
| 33 | /** @var ConstraintViolationList $errors */ | |
| 34 |         $errors = $this->get('validator')->validate($image, null, ['Api']); | |
| 35 | ||
| 36 |         if ($errors->count()) { | |
| 37 | $outErrors = []; | |
| 38 | ||
| 39 | /** @var ConstraintViolation $error */ | |
| 40 |             foreach ($errors as $error) { | |
| 41 | $outErrors['headers'][$error->getPropertyPath()] = $error->getMessage(); | |
| 42 | } | |
| 43 | ||
| 44 | throw new JsonHttpException(400, 'Bad Request', $outErrors); | |
| 45 | } | |
| 46 | $user->setImage($image); | |
| 47 | $this->getDoctrine()->getManager()->flush(); | |
| 48 | ||
| @@ 110-119 (lines=10) @@ | ||
| 107 | AbstractNormalizer::OBJECT_TO_POPULATE => $user | |
| 108 | ]); | |
| 109 |         $errors = $this->get('validator')->validate($user); | |
| 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, 'Bad Request', $outErrors); | |
| 119 | } | |
| 120 | $this->getDoctrine()->getManager()->flush(); | |
| 121 | ||
| 122 | return $this->json(['user' => $this->getUser()], 200, [], [AbstractNormalizer::GROUPS => ['Short']]); | |
| @@ 73-80 (lines=8) @@ | ||
| 70 | } | |
| 71 | ||
| 72 |         $errors = $this->get('validator')->validate($formRequest); | |
| 73 |         if ($errors->count()) { | |
| 74 | $outErrors = []; | |
| 75 | /** @var ConstraintViolation $error */ | |
| 76 |             foreach ($errors as $error) { | |
| 77 | $outErrors[$error->getPropertyPath()] = $error->getMessage(); | |
| 78 | } | |
| 79 | throw new JsonHttpException(400, 'Bad Request', $outErrors); | |
| 80 | } | |
| 81 | $em->persist($formRequest); | |
| 82 | $em->flush(); | |
| 83 | ||