@@ -65,13 +65,22 @@ class IsTrueValidator extends ConstraintValidator
65
65
const RECAPTCHA_VERIFY_SERVER = 'https://www.google.com ' ;
66
66
67
67
/**
68
- * @param bool $enabled
69
- * @param string $privateKey
70
- * @param RequestStack $requestStack
71
- * @param array $httpProxy
72
- * @param bool $verifyHost
68
+ * @param bool $enabled
69
+ * @param string $privateKey
70
+ * @param RequestStack $requestStack
71
+ * @param array $httpProxy
72
+ * @param bool $verifyHost
73
+ * @param AuthorizationCheckerInterface|null $authorizationChecker
74
+ * @param array $trusted_roles
73
75
*/
74
- public function __construct ($ enabled , $ privateKey , RequestStack $ requestStack , array $ httpProxy , $ verifyHost , AuthorizationCheckerInterface $ authorizationChecker , $ trusted_roles )
76
+ public function __construct (
77
+ $ enabled ,
78
+ $ privateKey ,
79
+ RequestStack $ requestStack ,
80
+ array $ httpProxy ,
81
+ $ verifyHost ,
82
+ AuthorizationCheckerInterface $ authorizationChecker = null ,
83
+ array $ trusted_roles = array ())
75
84
{
76
85
$ this ->enabled = $ enabled ;
77
86
$ this ->privateKey = $ privateKey ;
@@ -93,7 +102,7 @@ public function validate($value, Constraint $constraint)
93
102
}
94
103
95
104
// if we have an authorized role
96
- if ($ this ->authorizationChecker ->isGranted ($ this ->trusted_roles )) {
105
+ if ($ this ->authorizationChecker && $ this -> authorizationChecker ->isGranted ($ this ->trusted_roles )) {
97
106
return true ;
98
107
}
99
108
0 commit comments