Neos\Neos\Command\UserCommandController::removeRoleCommand PHP 메소드

removeRoleCommand() 공개 메소드

This command allows for removal of a specific role from an existing user. If an authentication provider was specified, the user will be determined by an account identified by "username" related to the given provider. However, once a user has been found, the role will be removed from all existing accounts related to that user, regardless of its authentication provider.
public removeRoleCommand ( string $username, string $role, string $authenticationProvider = null ) : void
$username string The username of the user
$role string Role to be removed from the user, for example "Neos.Neos:Administrator" or just "Administrator"
$authenticationProvider string Name of the authentication provider to use. Example: "Typo3BackendProvider"
리턴 void
    public function removeRoleCommand($username, $role, $authenticationProvider = null)
    {
        $user = $this->getUserOrFail($username, $authenticationProvider);
        try {
            if ($this->userService->removeRoleFromUser($user, $role) > 0) {
                $this->outputLine('Removed role "%s" from user "%s".', array($role, $username));
            } else {
                $this->outputLine('User "%s" did not have the role "%s" assigned.', array($username, $role));
            }
        } catch (NoSuchRoleException $exception) {
            $this->outputLine('The role "%s" does not exist.', array($role));
            $this->quit(2);
        }
    }