Skip to content

Commit

Permalink
MDL-71981 dataformat: indicate HTML support in writer callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden authored and abgreeve committed Jul 6, 2021
1 parent f77ff61 commit f3b3684
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dataformat/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
This files describes API changes in /dataformat/ download system,
information provided here is intended especially for developers.

=== 3.11.1 ===
* Optional $callback for the following \core\dataformat methods now receive a second argument to define
whether the current format writer supports HTML:
- download_data()
- write_data()
- write_data_to_filearea()

=== 3.9 ===
* The following methods have been added to the base dataformat class to allow instances to export to a local
file. They can be overridden in extending classes to define how files should be created:
Expand Down
7 changes: 4 additions & 3 deletions lib/classes/dataformat.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ protected static function get_format_instance(string $dataformat): \core\datafor
* @param string $dataformat
* @param array $columns
* @param Iterable $iterator
* @param callable|null $callback
* @param callable|null $callback Optional callback method to apply to each record prior to writing, which accepts two
* parameters as such: function($record, bool $supportshtml) returning formatted record
* @throws coding_exception
*/
public static function download_data(string $filename, string $dataformat, array $columns, Iterable $iterator,
Expand Down Expand Up @@ -90,7 +91,7 @@ public static function download_data(string $filename, string $dataformat, array
$rownum = 0;
foreach ($iterator as $row) {
if (is_callable($callback)) {
$row = $callback($row);
$row = $callback($row, $format->supports_html());
}
if ($row === null) {
continue;
Expand Down Expand Up @@ -132,7 +133,7 @@ public static function write_data(string $filename, string $dataformat, array $c
$rownum = 0;
foreach ($iterator as $row) {
if (is_callable($callback)) {
$row = $callback($row);
$row = $callback($row, $format->supports_html());
}
if ($row === null) {
continue;
Expand Down

0 comments on commit f3b3684

Please sign in to comment.