You are here

function advagg_admin_batch_rebuild in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 includes/admin.inc \advagg_admin_batch_rebuild()

Set up batch for first and last name loading.

This is where Drupal's Batch API comes into play. It's as simple as defining $batch, and then calling batch_set($batch)

1 string reference to 'advagg_admin_batch_rebuild'
advagg_admin_settings_form in ./advagg.admin.inc
Form builder; Configure advagg settings.

File

./advagg.admin.inc, line 587
Admin page callbacks for the advanced CSS/JS aggregation module.

Code

function advagg_admin_batch_rebuild($form, &$form_state) {
  $batch = array();

  // Set up the type of batch operation we will do.
  if ($form_state['clicked_button']['#post']['op'] == t('Force all counters to be increment by one')) {
    $increment = TRUE;
    $batch['title'] = t('Increment and rebuild aggregated files');
  }
  else {
    $increment = FALSE;
    $batch['title'] = t('Rebuilding aggregated files');
  }

  // Build batch operational data.
  $batch += array(
    'operations' => array(
      array(
        'advagg_admin_rebuild_bundles',
        array(
          $increment,
        ),
      ),
    ),
    'finished' => 'advagg_admin_rebuild_bundles_done',
    'init_message' => t('Initializing...'),
    'progress_message' => t('@current of @total batch operations done.'),
    'error_message' => t('Rebuilding aggregated files encountered an error.'),
    'file' => drupal_get_path('module', 'advagg') . '/advagg.admin.inc',
  );

  // Run it
  batch_set($batch);
  batch_process('admin/settings/advagg');
}