@@ -65,13 +65,22 @@ class IsTrueValidator extends ConstraintValidator
6565 const RECAPTCHA_VERIFY_SERVER = 'https://www.google.com ' ;
6666
6767 /**
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
7375 */
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 ())
7584 {
7685 $ this ->enabled = $ enabled ;
7786 $ this ->privateKey = $ privateKey ;
@@ -93,7 +102,7 @@ public function validate($value, Constraint $constraint)
93102 }
94103
95104 // if we have an authorized role
96- if ($ this ->authorizationChecker ->isGranted ($ this ->trusted_roles )) {
105+ if ($ this ->authorizationChecker && $ this -> authorizationChecker ->isGranted ($ this ->trusted_roles )) {
97106 return true ;
98107 }
99108
0 commit comments