Splitting off F from #1628044-33: Implement magic for the table of attachments on issues. As I wrote there:

However, instead of separate hook invocations, we could add another layer of nesting (keyed by 'visible' vs 'hidden') to the $rows and $headers arrays we pass to the alter hook. Hook implementations will have to know, but I think that's a reasonable API agreement to make in exchange for not doubling the # of hook invocations for this.

It makes things a bit more ugly for clients of this API, but it saves a lot of hook invocations. I think it's probably worth it, although I haven't looked closely enough at the new code (and all its various configuration options) to see how complicated this change would be.

Thoughts?
-Derek

CommentFileSizeAuthor
#2 1867102.patch11.4 KBjthorson

Comments

jthorson’s picture

Assigned: Unassigned » jthorson

The solution here is to build out the render array (no matter whether it contains one table or two based on the settings), and pass the entire render array to the alter() hook before output.

Working on this along with #1867094: Pass more context to hook_file_metadata_table_items_alter().

jthorson’s picture

StatusFileSize
new11.4 KB

Here's what I came up with ... also cleaned up generation of the second table, to eliminate a ton of duplicate code.

jthorson’s picture

Assigned: jthorson » Unassigned
jthorson’s picture

Status: Active » Needs review
jthorson’s picture

Status: Needs review » Fixed

Committed in 25ca17b.

dww’s picture

Haven't tested, but a brief skim of the code looks good. Thanks!

My only remaining concern would be renaming the alter hook to remove "rows" from the name. Perhaps hook_file_metadata_table_elements_alter() would be more appropriate given these changes?

Thanks again!
-Derek

jthorson’s picture

One step ahead of you ... that happened in the next commit ... renamed to hook_file_metadata_table_output_alter().

Status: Fixed » Closed (fixed)

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