Drupal module to store large amounts of data in files (csv, json, ...).
Usage examples:
<?php
$nids = array_keys(db_select('node', 'n')
->fields('n', array('nid'))
->condition('n.type', 'my_content_type')
->condition('n.status', 1)
->execute()
->fetchAllAssoc('nid'));
/**
* Example 1.
* Default usage.
*/
// Create a new Filer, this is an object that manages a set of files.
$filer = new Filer('example_one');
$options = array(
'items' => $nids, // Each one of these items is passed to the hooks one after another
'append' => TRUE, // Append or overwrite the contents of the file for every item, (e.a: CSV: append => TRUE, JSON: append => FALSE)
'read' => FALSE, // If TRUE the contents of our file will be passed to our hook (should be false if not used).
);
// Add a task to our Filer specifying the file to write to.
// If third param ($enqueue = TRUE) is FALSE, the task will not be added to the queue and needs to be run manually @see example_three
$filer->add('public://example_one.csv', $options);
/**
* Implements hook_filer_FILER_NAME_first();
* Only called for the first item.
*/
function hook_filer_example_one_first($item, $fh, $info) {
// $info['frid'] The frid of this file.
// $info['content'] The contents of the file if $options['read'] were TRUE.