Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 39 and 400]

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

return: dataformat\base
param: string $dataformat

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

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

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

return: stored_file
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