diff --git a/lib/classes/dataformat/base.php b/lib/classes/dataformat/base.php index d9fe32da04d..d00e46f537c 100644 --- a/lib/classes/dataformat/base.php +++ b/lib/classes/dataformat/base.php @@ -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. + } } diff --git a/lib/classes/dataformat/spout_base.php b/lib/classes/dataformat/spout_base.php index 9208e605b3f..6e622ea8beb 100644 --- a/lib/classes/dataformat/spout_base.php +++ b/lib/classes/dataformat/spout_base.php @@ -75,11 +75,11 @@ abstract class spout_base extends \core\dataformat\base { } /** - * Write the start of the format + * 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) { $this->writer->addRow(array_values((array)$columns)); } @@ -94,13 +94,10 @@ abstract class spout_base extends \core\dataformat\base { } /** - * Write the end of the format - * - * @param array $columns + * Write the end of the file. */ - public function write_footer($columns) { + public function close_output() { $this->writer->close(); $this->writer = null; } - }