synapsestudios/synapse-base — pull request #151 by paulstatezny (2014-12-19 21:19:54+00:00)
Title: Handle Deep Properties in Constraint Violation Responses

## Handle Deep Properties in Constraint Violation Responses

### Acceptance Criteria
1. `AbstractController::createConstraintViolationResponse` handles deep properties and displays them properly.

With constraint violation paths looking like this:
```
[2][foo]
[2][some_id]
[2][some_id]
[2][some_name]
[4][amount]
[4][foo]
[4][some_id]
[4][some_id]
[4][some_name]
```

Response body looks like this:
```JSON
{
"errors": [
null,
null,
{
"foo": [
"This field was not expected."
],
"some_id": [
"A validation message.",
"Some other validation constraint error."
],
"some_name": [
"Some error message."
]
},
null,
{
"amount": [
"This value should be of type integer."
],
"foo": [
"This field was not expected."
],
"some_id": [
"A validation message.",
"Some other validation constraint error."
],
"some_name": [
"Some error message."
]
}
]
}
```
### Tasks
- Extract object to perform conversion of constraint violations to arrays to be returned in a response.
- Implement an algorithm that converts the `[nested][0][property]` syntax of Symfony Validator into a properly nested array.

### Additional Notes
- Items that are just array elements (i.e. Have a numeric path like `[0]`) must be prefixed with a string, or upon conversion to JSON the numeric keys will be lost.
- Deep properties can exist if using the [All constraint](http://symfony.com/doc/current/reference/constraints/All.html) in Symfony Validator.