mapErrorCodes example

use Symfony\Component\Validator\ConstraintViolationList;

#[Package('core')] class ConstraintViolationException extends ShopwareHttpException
{
    private readonly ConstraintViolationList $violations;

    public function __construct(
        ConstraintViolationList $violations,
        private readonly array $inputData
    ) {
        $this->mapErrorCodes($violations);

        $this->violations = $violations;

        parent::__construct('Caught {{ count }} violation errors.', ['count' => $violations->count()]);
    }

    public function getRootViolations(): ConstraintViolationList
    {
        $violations = new ConstraintViolationList();
        foreach ($this->violations as $violation) {
            if ($violation->getPropertyPath() === '') {
                
Home | Imprint | This part of the site doesn't use cookies.