How to pass an instance to symfony form validator class?
问题 I am trying to create a custom symfony form validator constraint. I created two class, one constraint and one validator and it works fine. But I need to pass doctrine entitymanager instance to validator class, as I am using them standalone and not framework, I don't have yaml configuration file. I created a constructor in validator class to have $em, and in controller I have: ->add('email', EmailType::class, [ 'constraints' => [ new Assert\Email(['message' => 'invalid.email', 'mode' =>