mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-71981 dataformat: indicate HTML support in writer callback.
This commit is contained in:
parent
2feb383659
commit
61b4283c22
2 changed files with 11 additions and 3 deletions
|
@ -1,6 +1,13 @@
|
||||||
This files describes API changes in /dataformat/ download system,
|
This files describes API changes in /dataformat/ download system,
|
||||||
information provided here is intended especially for developers.
|
information provided here is intended especially for developers.
|
||||||
|
|
||||||
|
=== 3.10.5 ===
|
||||||
|
* 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 ===
|
=== 3.9 ===
|
||||||
* The following methods have been added to the base dataformat class to allow instances to export to a local
|
* 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:
|
file. They can be overridden in extending classes to define how files should be created:
|
||||||
|
|
|
@ -60,7 +60,8 @@ class dataformat {
|
||||||
* @param string $dataformat
|
* @param string $dataformat
|
||||||
* @param array $columns
|
* @param array $columns
|
||||||
* @param Iterable $iterator
|
* @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
|
* @throws coding_exception
|
||||||
*/
|
*/
|
||||||
public static function download_data(string $filename, string $dataformat, array $columns, Iterable $iterator,
|
public static function download_data(string $filename, string $dataformat, array $columns, Iterable $iterator,
|
||||||
|
@ -90,7 +91,7 @@ class dataformat {
|
||||||
$rownum = 0;
|
$rownum = 0;
|
||||||
foreach ($iterator as $row) {
|
foreach ($iterator as $row) {
|
||||||
if (is_callable($callback)) {
|
if (is_callable($callback)) {
|
||||||
$row = $callback($row);
|
$row = $callback($row, $format->supports_html());
|
||||||
}
|
}
|
||||||
if ($row === null) {
|
if ($row === null) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -132,7 +133,7 @@ class dataformat {
|
||||||
$rownum = 0;
|
$rownum = 0;
|
||||||
foreach ($iterator as $row) {
|
foreach ($iterator as $row) {
|
||||||
if (is_callable($callback)) {
|
if (is_callable($callback)) {
|
||||||
$row = $callback($row);
|
$row = $callback($row, $format->supports_html());
|
||||||
}
|
}
|
||||||
if ($row === null) {
|
if ($row === null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue