public function regenerateUsernamePasswordTokenWithRoles(array $roles, $mergeWithExistingRoles = true)
    {
        $user = $this->token->getUser();
        $credentials = $this->token->getCredentials();
        $providerKey = $this->token->getProviderKey();

        if ($mergeWithExistingRoles) {
            $roles = array_merge($roles, $this->token->getRoles());
        }

        $this->token = new UsernamePasswordToken($user, $credentials, $providerKey, $roles);
    }
public function regenerateUsernamePasswordTokenWithRoles(array $roles, $mergeWithExistingRoles = true)
    {
        $user = $this->token->getUser();
        $credentials = $this->token->getCredentials();
        $providerKey = $this->token->getProviderKey();

        if ($mergeWithExistingRoles) {
            $roles = array_merge($roles, $this->token->getRoles());
        }

        $this->token = new UsernamePasswordToken($user, $credentials, $providerKey, $roles);
    }
public function regenerateUsernamePasswordTokenWithRoles ( array $ roles , $ mergeWithExistingRoles = true ) { $ user = $ this -> token -> getUser ( ) ; $ credentials = $ this -> token -> getCredentials ( ) ; $ providerKey = $ this -> token -> getProviderKey ( ) ; if ( $ mergeWithExistingRoles ) { $ roles = array_merge ( $ roles , $ this -> token -> getRoles ( ) ) ; } $ this -> token = new UsernamePasswordToken ( $ user , $ credentials , $ providerKey , $ roles ) ; }
Regenerate same instance of this token with another roles

@param array $roles
@param bool $mergeWithExistingRoles
Regenerate same instance of this token with another roles