public function assign($role, UserInterface $user)
    {
        $roles = is_array($role) ? $role : [ $role ];

        $count = 0;

        foreach ($roles as $singleRole) {
            $count += $this->assignSingleRole($singleRole, $user) ? 1 : 0;
        }

        if ($count !== count($roles)) {
            return false;
        }

        $this->fireUserPermissionChangeEvent($user);
        return true;
    }
public function assign($role, UserInterface $user)
    {
        $roles = is_array($role) ? $role : [ $role ];

        $count = 0;

        foreach ($roles as $singleRole) {
            $count += $this->assignSingleRole($singleRole, $user) ? 1 : 0;
        }

        if ($count !== count($roles)) {
            return false;
        }

        $this->fireUserPermissionChangeEvent($user);
        return true;
    }
public function assign ( $ role , UserInterface $ user ) { $ roles = is_array ( $ role ) ? $ role : [ $ role ] ; $ count = 0 ; foreach ( $ roles as $ singleRole ) { $ count += $ this -> assignSingleRole ( $ singleRole , $ user ) ? 1 : 0 ; } if ( $ count !== count ( $ roles ) ) { return false ; } $ this -> fireUserPermissionChangeEvent ( $ user ) ; return true ; }
Assigns one or several roles to a user.

@param string|string[] $role
@param UserInterface   $user
@return bool
Assigns one or several roles to a user .