symfony/symfony — pull request #8314 by cristianoc72 (2013-06-19 22:55:58+00:00)
Title: [Validator] Add ConstraintViolationList::toArray method

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |

Add `toArray` method to `ConstraintViolationListClass`.

This method returns the violations, included in the list, as an associative array:

```php
$violationsArray = array(
'Root 1' => array(
'Property1.1' => array('Error message 1'),
'Property2.1' => array('Error message 2', .... , 'Error message n'),
.........
),
'Root 2' => array(
'Property2.1' => array('Error message 3', 'Error message 4', ........),
........
)
);
```

As you certainly know, Propel2 validation sub-system is based on Symfony Validator Component.
Some Propel users asked us for this feature (See https://github.com/propelorm/Propel2/issues/413 and the discussion here https://github.com/propelorm/Propel2/pull/414) so we decided first to submit this PR, in case you consider this feature useful also for Symfony community.