Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 39 and 311]

Class containing utility methods for dataformats

Copyright: 2020 Paul Holden <paulh@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 170 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

dataformat:: (4 methods):
  get_format_instance()
  download_data()
  write_data()
  write_data_to_filearea()


Class: dataformat  - X-Ref

Dataformat utility class

get_format_instance(string $dataformat)   X-Ref
Return an instance of a dataformat writer from given dataformat type

param: string $dataformat
return: dataformat\base

download_data(string $filename, string $dataformat, array $columns, Iterable $iterator,callable $callback = null)   X-Ref
Sends a formatted data file to the browser

param: string $filename
param: string $dataformat
param: array $columns
param: Iterable $iterator
param: callable|null $callback Optional callback method to apply to each record prior to writing, which accepts two

write_data(string $filename, string $dataformat, array $columns, Iterable $iterator,callable $callback = null)   X-Ref
Writes a formatted data file with specified filename

param: string $filename
param: string $dataformat
param: array $columns
param: Iterable $iterator
param: callable|null $callback
return: string Complete path to the file on disk

write_data_to_filearea(array $filerecord, string $dataformat, array $columns, Iterable $iterator,callable $callback = null)   X-Ref
Writes a formatted data file to file storage

param: array $filerecord File record for storage, 'filename' extension should be omitted as it's added by the dataformat
param: string $dataformat
param: array $columns
param: Iterable $iterator Iterable set of records to write
param: callable|null $callback Optional callback method to apply to each record prior to writing
return: stored_file