|
@@ 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']]); |