| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function onErrorFormatting(ErrorFormattingEvent $event) :void |
||
| 14 | { |
||
| 15 | $error = $event->getError()->getPrevious(); |
||
| 16 | |||
| 17 | if ($error instanceof ValidationException) { |
||
| 18 | $errors = []; |
||
| 19 | |||
| 20 | $violations = $error->getViolations(); |
||
| 21 | foreach($violations as $violation) { |
||
| 22 | $errors[] = [ |
||
| 23 | 'field' => $violation->getPropertyPath(), |
||
| 24 | 'message' => $violation->getMessage(), |
||
| 25 | ]; |
||
| 26 | } |
||
| 27 | |||
| 28 | $formattedError = $event->getFormattedError(); |
||
| 29 | $formattedError->offsetSet('fields', $errors); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 |