@@ -63,6 +63,11 @@ class ConstraintViolation implements ConstraintViolationInterface
63
63
*/
64
64
private $ code ;
65
65
66
+ /**
67
+ * @var mixed
68
+ */
69
+ private $ cause ;
70
+
66
71
/**
67
72
* Creates a new constraint violation.
68
73
*
@@ -79,10 +84,11 @@ class ConstraintViolation implements ConstraintViolationInterface
79
84
* @param int|null $plural The number for determining the plural
80
85
* form when translating the message
81
86
* @param mixed $code The error code of the violation
82
- * @param Constraint|null $constraint The constraint that caused the
83
- * violation
87
+ * @param Constraint|null $constraint The constraint whose validation
88
+ * caused the violation
89
+ * @param mixed $cause The cause of the violation
84
90
*/
85
- public function __construct ($ message , $ messageTemplate , array $ parameters , $ root , $ propertyPath , $ invalidValue , $ plural = null , $ code = null , Constraint $ constraint = null )
91
+ public function __construct ($ message , $ messageTemplate , array $ parameters , $ root , $ propertyPath , $ invalidValue , $ plural = null , $ code = null , Constraint $ constraint = null , $ cause = null )
86
92
{
87
93
$ this ->message = $ message ;
88
94
$ this ->messageTemplate = $ messageTemplate ;
@@ -93,6 +99,7 @@ public function __construct($message, $messageTemplate, array $parameters, $root
93
99
$ this ->invalidValue = $ invalidValue ;
94
100
$ this ->constraint = $ constraint ;
95
101
$ this ->code = $ code ;
102
+ $ this ->cause = $ cause ;
96
103
}
97
104
98
105
/**
@@ -197,7 +204,7 @@ public function getInvalidValue()
197
204
}
198
205
199
206
/**
200
- * Returns the constraint that caused the violation.
207
+ * Returns the constraint whose validation caused the violation.
201
208
*
202
209
* @return Constraint|null The constraint or null if it is not known
203
210
*/
@@ -206,6 +213,16 @@ public function getConstraint()
206
213
return $ this ->constraint ;
207
214
}
208
215
216
+ /**
217
+ * Returns the cause of the violation.
218
+ *
219
+ * @return mixed
220
+ */
221
+ public function getCause ()
222
+ {
223
+ return $ this ->cause ;
224
+ }
225
+
209
226
/**
210
227
* {@inheritdoc}
211
228
*/
0 commit comments