Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core\dataformat Class Reference

Dataformat utility class. More...

Static Public Member Functions

static download_data (string $filename, string $dataformat, array $columns, Iterable $iterator, callable $callback=null)
 Sends a formatted data file to the browser.
 
static write_data (string $filename, string $dataformat, array $columns, Iterable $iterator, callable $callback=null)
 Writes a formatted data file with specified filename.
 
static write_data_to_filearea (array $filerecord, string $dataformat, array $columns, Iterable $iterator, callable $callback=null)
 Writes a formatted data file to file storage.
 

Static Protected Member Functions

static get_format_instance (string $dataformat)
 Return an instance of a dataformat writer from given dataformat type.
 

Detailed Description

Dataformat utility class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ download_data()

static core\dataformat::download_data ( string $filename,
string $dataformat,
array $columns,
Iterable $iterator,
callable $callback = null )
static

Sends a formatted data file to the browser.

Parameters
string$filename
string$dataformat
array$columns
Iterable$iterator
callable | null$callbackOptional callback method to apply to each record prior to writing, which accepts two parameters as such: function($record, bool $supportshtml) returning formatted record
Exceptions
coding_exception

◆ get_format_instance()

static core\dataformat::get_format_instance ( string $dataformat)
staticprotected

Return an instance of a dataformat writer from given dataformat type.

Parameters
string$dataformat
Return values
dataformat\base
Exceptions
coding_exception

◆ write_data()

static core\dataformat::write_data ( string $filename,
string $dataformat,
array $columns,
Iterable $iterator,
callable $callback = null )
static

Writes a formatted data file with specified filename.

Parameters
string$filename
string$dataformat
array$columns
Iterable$iterator
callable | null$callback
Return values
stringComplete path to the file on disk

◆ write_data_to_filearea()

static core\dataformat::write_data_to_filearea ( array $filerecord,
string $dataformat,
array $columns,
Iterable $iterator,
callable $callback = null )
static

Writes a formatted data file to file storage.

Parameters
array$filerecordFile record for storage, 'filename' extension should be omitted as it's added by the dataformat
string$dataformat
array$columns
Iterable$iteratorIterable set of records to write
callable | null$callbackOptional callback method to apply to each record prior to writing
Return values
stored_file

The documentation for this class was generated from the following file: