Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 2 | public function getErrorResponse(ConstraintViolationListInterface $errors) |
|
18 | { |
||
19 | 2 | return new JsonResponse([ |
|
20 | 2 | 'message' => 'Validation error. Please check your data.', //todo translate this message |
|
21 | 2 | 'errors' => array_map(function (ConstraintViolation $violation) { |
|
22 | // todo find the way to show correct path to property. |
||
23 | // Assert\* will return path like "[registration][username]" |
||
24 | // But UniqueEntity will return path like "username" |
||
25 | return [ |
||
26 | 2 | 'path' => $violation->getPropertyPath(), |
|
27 | 2 | 'message' => $violation->getMessage(), |
|
28 | ]; |
||
29 | 2 | }, iterator_to_array($errors)), |
|
30 | 2 | ], 400); |
|
31 | } |
||
32 | } |