ViolationMapper example

private const LEVEL_2 = 3;

    private EventDispatcher $dispatcher;
    private ViolationMapper $mapper;
    private string $message;
    private string $messageTemplate;
    private array $params;

    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();
        $this->mapper = new ViolationMapper();
        $this->message = 'Message';
        $this->messageTemplate = 'Message template';
        $this->params = ['foo' => 'bar'];
    }

    protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = []$inheritData = false, $synchronized = true, array $options = [])
    {
        $config = new FormConfigBuilder($name$dataClass$this->dispatcher, [
            'error_mapping' => $errorMapping,
        ] + $options);
        $config->setMapped($options['mapped'] ?? true);
        

class FormTypeValidatorExtension extends BaseValidatorExtension
{
    private ValidatorInterface $validator;
    private ViolationMapper $violationMapper;
    private bool $legacyErrorMessages;

    public function __construct(ValidatorInterface $validator, bool $legacyErrorMessages = true, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)
    {
        $this->validator = $validator;
        $this->violationMapper = new ViolationMapper($formRenderer$translator);
    }

    /** * @return void */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventSubscriber(new ValidationListener($this->validator, $this->violationMapper));
    }

    /** * @return void */
class ValidationListenerTest extends TestCase
{
    private ValidatorInterface $validator;
    private ValidationListener $listener;
    private string $message;
    private string $messageTemplate;
    private array $params;

    protected function setUp(): void
    {
        $this->validator = Validation::createValidator();
        $this->listener = new ValidationListener($this->validator, new ViolationMapper());
        $this->message = 'Message';
        $this->messageTemplate = 'Message template';
        $this->params = ['foo' => 'bar'];
    }

    private function createForm($name = '', $compound = false)
    {
        $config = new FormBuilder($name, null, new EventDispatcher()(new FormFactoryBuilder())->getFormFactory());
        $config->setCompound($compound);

        if ($compound) {
            
Home | Imprint | This part of the site doesn't use cookies.