You are here

function patterns_batch_finish in Patterns 7.2

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_batch_finish()
  2. 6 patterns.module \patterns_batch_finish()
  3. 7 includes/core/batch.inc \patterns_batch_finish()

Finishes a batch operation.

When a section has been executed, check its status and print an output to screen

Parameters

$success boolean Whether the section was completed (with or without errors):

$results array Detailed report of the execution of the section:

@operations array Additional information by the batch (not used for now):

1 string reference to 'patterns_batch_finish'
patterns_execute_pattern_batch in includes/core/batch.inc
Starts preliminary operations for pattern execution.

File

includes/core/batch.inc, line 187
Running patterns using Drupal's batch API.

Code

function patterns_batch_finish($success, $results, $operations) {
  $info = $_SESSION['patterns_batch_info'];
  $pid = key($info);
  $pattern = $info[$pid];
  $section = $results['section'];
  if (empty($results['abort'])) {
    _patterns_section_success($pid, $pattern['title'], $section);
  }
  else {
    _patterns_section_fail($pid, $pattern['title'], $section, $results['error_message']);
  }

  // If this is the last section to finish, unset all $_SESSION variables
  // and flush caches
  $_SESSION['patterns_batch_counter']++;
  if ($_SESSION['patterns_batch_counter'] >= $_SESSION['patterns_batch_total']) {
    unset($_SESSION['patterns_batch_info']);
    unset($_SESSION['patterns_batch_counter']);
    unset($_SESSION['patterns_batch_total']);
    drupal_flush_all_caches();
  }
}