Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 39 and 401]

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