Created
December 4, 2020 11:51
-
-
Save mdzwigala/36a6e2a817bd24d8e2bd1931e23455ae to your computer and use it in GitHub Desktop.
ADR-EXAMPLE\Infrastructure\SymfonyViolationListConverter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Infrastructure\Service; | |
use Symfony\Component\Validator\ConstraintViolation; | |
use Symfony\Component\Validator\ConstraintViolationListInterface; | |
final class SymfonyViolationListConverter | |
{ | |
public function convertToArray(ConstraintViolationListInterface $list): array | |
{ | |
$errors = []; | |
/** @var ConstraintViolation $violation */ | |
foreach ($list as $violation) { | |
$errors[$violation->getPropertyPath()][] = $violation->getMessage(); | |
} | |
return $errors; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment