https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41620

--- Comment #19 from David Nind <[email protected]> ---
Created attachment 203502
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203502&action=edit
Bug 41620: Add subclass export contract to Koha::CSV

This patch adds a high-level export API to Koha::CSV that provides a
clean contract for subclasses defining CSV exports.

New methods:
- columns(): subclass override point returning arrayref of
  { header, value } column definitions
- export($fh, $iterator, \%params): full workflow handling UTF-8
  BOM, headers, and row iteration. Supports no_headers param
- init_output($fh): sets UTF-8 encoding layer + BOM for
  Excel/LibreOffice compatibility
- headers(): derives header strings from columns()
- print_headers($fh): prints header row
- format_row($object): applies value coderefs from columns()

Subclasses only need to override columns():

    sub columns {
        return [
            { header => __("Name"), value => sub { $_[0]->name } },
        ];
    }

The existing low-level API (combine, string, print, parse, etc.)
is preserved for direct usage outside the subclass pattern.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/Koha/CSV.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: David Nind <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to