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:
hook_editoria11y_export_header_alter: To add or modify CSV column headers.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
- Review.
- Commit.
User interface changes
None
API changes
This patch introduces two new API hooks:
-
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, ordismissals).
-
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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | allow-header-and-row-alter-3569711-2.patch | 2.83 KB | mister. jones |
Comments
Comment #2
mister. jones commentedComment #3
itmaybejj commentedI'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.
Comment #4
mteca commentedFor me it works https://www.drupal.org/project/editoria11y/issues/3569711#comment-16442805.
Comment #6
itmaybejj commentedComment #8
itmaybejj commentedThank you both. Merged into 2.2.21