mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-52046 reportbuilder: Support null return from checkbox callback
This commit is contained in:
parent
2bf886f9dd
commit
1b1128d646
8
.upgradenotes/MDL-52046-2024061805141748.yml
Normal file
8
.upgradenotes/MDL-52046-2024061805141748.yml
Normal file
@ -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
|
@ -143,7 +143,7 @@ abstract class system_report extends base {
|
||||
* 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;
|
||||
@ -166,7 +166,11 @@ abstract class system_report extends base {
|
||||
$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, [
|
||||
|
Loading…
x
Reference in New Issue
Block a user