public function createViolationErrorResponse(ViolationListException $exception)
    {
        $errorData = [];

        /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
        foreach ($exception->getViolationList() as $violation) {
            $errorData[$violation->getPropertyPath()] = $violation->getMessage();
        }

        // Try get code from errors storage via exception
        $errors = $this->handler->getErrors();
        $code = $errors->hasException($exception) ? $errors->getExceptionCode($exception) : 0;

        return $this->createErrorResponse($code, null, $errorData);
    }
public function createViolationErrorResponse(ViolationListException $exception)
    {
        $errorData = [];

        /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
        foreach ($exception->getViolationList() as $violation) {
            $errorData[$violation->getPropertyPath()] = $violation->getMessage();
        }

        // Try get code from errors storage via exception
        $errors = $this->handler->getErrors();
        $code = $errors->hasException($exception) ? $errors->getExceptionCode($exception) : 0;

        return $this->createErrorResponse($code, null, $errorData);
    }
public function createViolationErrorResponse ( ViolationListException $ exception ) { $ errorData = [ ] ; /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */ foreach ( $ exception -> getViolationList ( ) as $ violation ) { $ errorData [ $ violation -> getPropertyPath ( ) ] = $ violation -> getMessage ( ) ; } // Try get code from errors storage via exception $ errors = $ this -> handler -> getErrors ( ) ; $ code = $ errors -> hasException ( $ exception ) ? $ errors -> getExceptionCode ( $ exception ) : 0 ; return $ this -> createErrorResponse ( $ code , null , $ errorData ) ; }
Create violation error response

@param ViolationListException $exception

@return JsonResponse
Create violation error response