function batch_append_to_batch_file
Search API
| 7.x batch.module | batch_append_to_batch_file($batch, $content, $filetype = 'csv') |
This will append to a file, stored in custom/files/private, which will use the batch id as its filename. If the file does not exist, it will be be created. $batch is the array returned by $content is the string contents we wish to add to the file. $filetype is the ext of the file, which gives us a clue of the file type.
See also
File
- modules/
batch/ batch.module, line 151
Code
function batch_append_to_batch_file($batch, $content, $filetype = 'csv') {
$private_path = fp_get_files_path() . "/private";
$batch_id = $batch ['batch_id'];
$created = $batch ['created'];
$filename = $private_path . '/batch_' . $batch_id . '__' . $created . '.' . $filetype . '.tmp';
if (!file_exists($filename)) {
file_put_contents($filename, ''); // Just create the file.
}
// Now, append to it...
file_put_contents($filename, $content, FILE_APPEND);
}
