MDL-56046 core_dataformat: added functions to support multiple sheets

Also removed write_header() and write_footer(). The reason for this
is because in core we want to know if the format being used supports
multiple sheets. To do this, and ensure we do not break third-party
dataformat plugins, we are using method_exist(). If write_header()
and write_footer() remain in the base class then this will always
be true.
This commit is contained in:
Mark Nelson
2017-06-26 13:29:32 +08:00
parent f4a2d69631
commit b62b5879af
2 changed files with 21 additions and 13 deletions
+17 -6
View File
@@ -76,8 +76,6 @@ abstract class base {
* Output file headers to initialise the download of the file.
*/
public function send_http_headers() {
global $CFG;
if (defined('BEHAT_SITE_RUNNING')) {
// For text based formats - we cannot test the output with behat if we force a file download.
return;
@@ -98,11 +96,18 @@ abstract class base {
}
/**
* Write the start of the format
* Write the start of the file.
*/
public function start_output() {
// Override me if needed.
}
/**
* Write the start of the sheet we will be adding data to.
*
* @param array $columns
*/
public function write_header($columns) {
public function start_sheet($columns) {
// Override me if needed.
}
@@ -115,12 +120,18 @@ abstract class base {
abstract public function write_record($record, $rownum);
/**
* Write the end of the format
* Write the end of the sheet containing the data.
*
* @param array $columns
*/
public function write_footer($columns) {
public function close_sheet($columns) {
// Override me if needed.
}
/**
* Write the end of the file.
*/
public function close_output() {
// Override me if needed.
}
}