public function addRole($username, $role)
    {
        $user = $this->findUserByUsernameOrThrowException($username);
        if ($user->hasRole($role)) {
            return false;
        }

        $user->addRole($role);
        $this->userManager->updateUser($user);

        return true;
    }
public function addRole($username, $role)
    {
        $user = $this->findUserByUsernameOrThrowException($username);
        if ($user->hasRole($role)) {
            return false;
        }

        $user->addRole($role);
        $this->userManager->updateUser($user);

        return true;
    }
public function addRole ( $ username , $ role ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; if ( $ user -> hasRole ( $ role ) ) { return false ; } $ user -> addRole ( $ role ) ; $ this -> userManager -> updateUser ( $ user ) ; return true ; }
Adds role to the given user.

@param string $username
@param string $role

@return bool true if role was added, false if user already had the role
Adds role to the given user .