| @@ 69-78 (lines=10) @@ | ||
| 66 | ); |
|
| 67 | ||
| 68 | $errors = $this->get('validator')->validate($formRequest); |
|
| 69 | if ($errors->count()) { |
|
| 70 | $outErrors = []; |
|
| 71 | ||
| 72 | /** @var ConstraintViolation $error */ |
|
| 73 | foreach ($errors as $error) { |
|
| 74 | $outErrors[$error->getPropertyPath()] = $error->getMessage(); |
|
| 75 | } |
|
| 76 | ||
| 77 | throw new JsonHttpException(400, 'Bad Request', $outErrors); |
|
| 78 | } |
|
| 79 | ||
| 80 | $em->persist($formRequest); |
|
| 81 | $em->flush(); |
|
| @@ 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']]); |
|