You are here

function gc_update_finished in GatherContent 8

Finished callback.

@inheritdoc

1 string reference to 'gc_update_finished'
gc_views_vbo_update in ./_old.gc.module
Submit callback for `views_bulk_operations_confirm_form`.

File

./_old.gc.module, line 485

Code

function gc_update_finished($success, $results, $operations) {
  if ($success) {

    // Select all items with uuid.
    $query = new EntityFieldQuery();
    $result = $query
      ->entityCondition('entity_type', 'gc_operation_item')
      ->propertyCondition('operation_uuid', $results['uuid'])
      ->execute();
    if (isset($result['gc_operation_item'])) {
      $operation_items = \Drupal::entityManager()
        ->getStorage('gc_operation_item');
      $success_counter = 0;
      foreach ($operation_items as $operation_item) {
        if ($operation_item->status === 'Success') {
          $success_counter++;
        }
      }
      $unsuccessful = count($result['gc_operation_item']) - $success_counter;
      drupal_set_message(\Drupal::translation()
        ->formatPlural($success_counter, '1 item was updated successfully.', '@count items were updated successfully.'));
      if ($unsuccessful > 0) {
        drupal_set_message(\Drupal::translation()
          ->formatPlural($unsuccessful, '1 item was not updated. Check errors below.', '@count items were not updated. Check errors below.'), 'error');
      }
    }
    drupal_goto('admin/content/update/result/' . $results['uuid']);
  }
  else {
    $error_operation = reset($operations);
    drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array(
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    )), 'error');
  }
}