File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/DataDog/AuditBundle/EventSubscriber Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -495,14 +495,28 @@ private function getImpersonatorUserFromSecurityToken($token)
495495 if (!$ token instanceof TokenInterface) {
496496 return null ;
497497 }
498- foreach ($ token ->getRoles () as $ role ) {
498+
499+ foreach ($ this ->getRoles ($ token ) as $ role ) {
499500 if ($ role instanceof SwitchUserRole) {
500501 return $ role ->getSource ()->getUser ();
501502 }
502503 }
503504 return null ;
504505 }
505506
507+ /**
508+ * @param TokenInterface $token
509+ * @return array
510+ */
511+ private function getRoles (TokenInterface $ token )
512+ {
513+ if (method_exists ($ token , 'getRoleNames ' )){
514+ return $ token ->getRoleNames ();
515+ }
516+
517+ return $ token ->getRoles ();
518+ }
519+
506520 public function getSubscribedEvents ()
507521 {
508522 return [Events::onFlush];
You can’t perform that action at this time.
0 commit comments