mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
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:
parent
f4a2d69631
commit
b62b5879af
@ -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.
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user