By default symfony validator violations looks like this
[0] => -message: "This value should not be blank."
-propertyPath: "name"
[1] => -message: "This value should not be blank."
-propertyPath: "productVarieties[0].name"
How can I convert this to a multidimensional array, so that productVarieties[0] will be nested inside a root array key?
I've tried using the property access component, but it seems like property path is in the wrong format
foreach ($violations as $violation) {
$this->propertyAccessor->setValue($errors, $violation->getPropertyPath(), $violation->getMessage());
}
Exception class: "Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException" message: "Cannot write property "name" to an array. Maybe you should write the property path as "[name]" instead?"