private function deleteRole($roles)
    {
        $result = [];
        try {
            foreach ($roles as $value) {
                $role = $this->entityTypeManager->getStorage('user_role')->load($value);
                $this->entityTypeManager->getStorage('user_role')->delete([$role]);

                $result['success'][] = [
                    'role-id' => $value,
                    'role-name' => $value
                ];
            }
        } catch (\Exception $e) {
            $result['error'] = [
                'error' => 'Error: ' . get_class($e) . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage()
            ];
        }

        return $result;
    }
private function deleteRole($roles)
    {
        $result = [];
        try {
            foreach ($roles as $value) {
                $role = $this->entityTypeManager->getStorage('user_role')->load($value);
                $this->entityTypeManager->getStorage('user_role')->delete([$role]);

                $result['success'][] = [
                    'role-id' => $value,
                    'role-name' => $value
                ];
            }
        } catch (\Exception $e) {
            $result['error'] = [
                'error' => 'Error: ' . get_class($e) . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage()
            ];
        }

        return $result;
    }
private function deleteRole ( $ roles ) { $ result = [ ] ; try { foreach ( $ roles as $ value ) { $ role = $ this -> entityTypeManager -> getStorage ( 'user_role' ) -> load ( $ value ) ; $ this -> entityTypeManager -> getStorage ( 'user_role' ) -> delete ( [ $ role ] ) ; $ result [ 'success' ] [ ] = [ 'role-id' => $ value , 'role-name' => $ value ] ; } } catch ( \ Exception $ e ) { $ result [ 'error' ] = [ 'error' => 'Error: ' . get_class ( $ e ) . ', code: ' . $ e -> getCode ( ) . ', message: ' . $ e -> getMessage ( ) ] ; } return $ result ; }
Remove and returns an array of deleted roles

@param $roles

@return $array
Remove and returns an array of deleted roles