Problem/Motivation

Currently, the CSV headers and row data in ExportCSVController are hardcoded. This makes it impossible for other modules to modify the export data—for example, to add internal tracking IDs, extra content fields, or custom prioritization logic—without completely overriding the controller or the route.

Developers need a way to inject custom columns and data into the Accessibility reports to better integrate Editoria11y with external reporting workflows.

Proposed resolution

Introduce \Drupal::moduleHandler()->alter() calls within the ExportCSVController methods (pages, issues, and dismissals).

This patch adds two new alter hooks:

  1. hook_editoria11y_export_header_alter: To add or modify CSV column headers.
  2. hook_editoria11y_export_row_alter: To inject or modify the data for a specific row.

These hooks pass a $context_key (e.g., 'pages', 'issues') so implementations can target specific export types.

Remaining tasks

  1. Review.
  2. Commit.

User interface changes

None

API changes

This patch introduces two new API hooks:

  1. hook_editoria11y_export_header_alter(array &$header, string $context_key):
    • $header: The associative array of CSV headers.
    • $context_key: A string indicating the export type (pages, issues, or dismissals).
  2. hook_editoria11y_export_row_alter(array &$data, $result, string $context_key):
    • $data: The associative array of row data to be written to the CSV.
    • $result: The original result object (stdClass) from the dashboard query, containing the raw data for the current row.
    • $context_key: A string indicating the export type.

Data model changes

None

Comments

mister. jones created an issue. See original summary.

mister. jones’s picture

StatusFileSize
new2.83 KB
itmaybejj’s picture

Assigned: Unassigned » itmaybejj

I'll take a look. Worth noting that all this code goes away in v3, replaced by exportable Views that can be edited directly in the GUI. I am on track to have v3 into beta within the next few weeks, so if you are planning to update you might not want to spend much time coding against the 2.x branch.

mteca’s picture

  • itmaybejj committed 3036a0f3 on 2.2.x
    feat: #3569711 Add hook_editoria11y_export_header_alter and row_alter to...
itmaybejj’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

itmaybejj’s picture

Thank you both. Merged into 2.2.21

  • itmaybejj committed 3036a0f3 on 2.2.x-dev
    feat: #3569711 Add hook_editoria11y_export_header_alter and row_alter to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.