@@ -114,39 +114,22 @@ public function validate($form, Constraint $constraint)
114
114
? (string ) $ form ->getViewData ()
115
115
: gettype ($ form ->getViewData ());
116
116
117
- if ($ this ->context instanceof ExecutionContextInterface) {
118
- $ this ->context ->buildViolation ($ config ->getOption ('invalid_message ' ))
119
- ->setParameters (array_replace (array ('{{ value }} ' => $ clientDataAsString ), $ config ->getOption ('invalid_message_parameters ' )))
120
- ->setInvalidValue ($ form ->getViewData ())
121
- ->setCode (Form::NOT_SYNCHRONIZED_ERROR )
122
- ->setCause ($ form ->getTransformationFailure ())
123
- ->addViolation ();
124
- } else {
125
- $ this ->buildViolation ($ config ->getOption ('invalid_message ' ))
126
- ->setParameters (array_replace (array ('{{ value }} ' => $ clientDataAsString ), $ config ->getOption ('invalid_message_parameters ' )))
127
- ->setInvalidValue ($ form ->getViewData ())
128
- ->setCode (Form::NOT_SYNCHRONIZED_ERROR )
129
- ->setCause ($ form ->getTransformationFailure ())
130
- ->addViolation ();
131
- }
117
+ $ this ->context ->buildViolation ($ config ->getOption ('invalid_message ' ))
118
+ ->setParameters (array_replace (array ('{{ value }} ' => $ clientDataAsString ), $ config ->getOption ('invalid_message_parameters ' )))
119
+ ->setInvalidValue ($ form ->getViewData ())
120
+ ->setCode (Form::NOT_SYNCHRONIZED_ERROR )
121
+ ->setCause ($ form ->getTransformationFailure ())
122
+ ->addViolation ();
132
123
}
133
124
}
134
125
135
126
// Mark the form with an error if it contains extra fields
136
127
if (!$ config ->getOption ('allow_extra_fields ' ) && count ($ form ->getExtraData ()) > 0 ) {
137
- if ($ this ->context instanceof ExecutionContextInterface) {
138
- $ this ->context ->buildViolation ($ config ->getOption ('extra_fields_message ' ))
139
- ->setParameter ('{{ extra_fields }} ' , implode ('", " ' , array_keys ($ form ->getExtraData ())))
140
- ->setInvalidValue ($ form ->getExtraData ())
141
- ->setCode (Form::NO_SUCH_FIELD_ERROR )
142
- ->addViolation ();
143
- } else {
144
- $ this ->buildViolation ($ config ->getOption ('extra_fields_message ' ))
145
- ->setParameter ('{{ extra_fields }} ' , implode ('", " ' , array_keys ($ form ->getExtraData ())))
146
- ->setInvalidValue ($ form ->getExtraData ())
147
- ->setCode (Form::NO_SUCH_FIELD_ERROR )
148
- ->addViolation ();
149
- }
128
+ $ this ->context ->buildViolation ($ config ->getOption ('extra_fields_message ' ))
129
+ ->setParameter ('{{ extra_fields }} ' , implode ('", " ' , array_keys ($ form ->getExtraData ())))
130
+ ->setInvalidValue ($ form ->getExtraData ())
131
+ ->setCode (Form::NO_SUCH_FIELD_ERROR )
132
+ ->addViolation ();
150
133
}
151
134
}
152
135
0 commit comments