Skip to content

Commit

Permalink
MDL-52046 reportbuilder: Support null return from checkbox callback
Browse files Browse the repository at this point in the history
  • Loading branch information
davewoloszyn committed Jun 18, 2024
1 parent 2bf886f commit 1b1128d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .upgradenotes/MDL-52046-2024061805141748.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
issueNumber: MDL-52046
notes:
core_reportbuilder:
- message: >-
The return type of the `set_checkbox_toggleall` callback, defined by
system reports, can now be null. Use if the checkbox should not be shown
for the row.
type: improved
8 changes: 6 additions & 2 deletions reportbuilder/classes/system_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ final public function get_base_fields(): array {
* Define toggle all checkbox for the report, required row data should be defined by calling {@see add_base_fields}
*
* @param callable $callback Callback to return value/label for each checkbox, implementing the following signature:
* function(stdClass $row): array containing value/label pair
* function(stdClass $row): ?array containing value/label pair, or null if the checkbox should not be shown for the row
*/
final protected function set_checkbox_toggleall(callable $callback): void {
$this->checkboxcallback = $callback;
Expand All @@ -166,7 +166,11 @@ final public function get_checkbox_toggleall(bool $ismaster, ?stdClass $row = nu
$value = '';
$label = get_string('selectall');
} else {
[$value, $label] = ($this->checkboxcallback)($row);
$checkboxdata = ($this->checkboxcallback)($row);
if ($checkboxdata === null) {
return null;
}
[$value, $label] = $checkboxdata;
}

return new checkbox_toggleall('report-select-all', $ismaster, [
Expand Down

0 comments on commit 1b1128d

Please sign in to comment.