public function getImpersonatingUser()
    {
        if ($this->isGranted('ROLE_PREVIOUS_ADMIN')) {
            foreach ($this->tokenStorage->getToken()->getRoles() as $role) {
                if ($role instanceof SwitchUserRole) {
                    return $role->getSource()->getUser();
                }
            }
        }
    }
public function getImpersonatingUser()
    {
        if ($this->isGranted('ROLE_PREVIOUS_ADMIN')) {
            foreach ($this->tokenStorage->getToken()->getRoles() as $role) {
                if ($role instanceof SwitchUserRole) {
                    return $role->getSource()->getUser();
                }
            }
        }
    }
public function getImpersonatingUser ( ) { if ( $ this -> isGranted ( 'ROLE_PREVIOUS_ADMIN' ) ) { foreach ( $ this -> tokenStorage -> getToken ( ) -> getRoles ( ) as $ role ) { if ( $ role instanceof SwitchUserRole ) { return $ role -> getSource ( ) -> getUser ( ) ; } } } }
When impersonating a user, it returns the original user who started
the impersonation.

@return mixed
When impersonating a user it returns the original user who started the impersonation .