You are here

function processContentBatch in Content Synchronization 8

Processes the content single import batch

Parameters

$data: The batch content to persist.

array $context: The batch context.

1 string reference to 'processContentBatch'
ContentSingleImportForm::submitForm in src/Form/ContentSingleImportForm.php
Form submission handler.

File

./content_sync.batch.inc, line 14

Code

function processContentBatch($data, &$context) {

  // Initialize Batch
  if (empty($context['sandbox'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['current_number'] = 0;
    if (isset($data['values'])) {
      $context['sandbox']['max'] = (int) count($data['values']);
    }
    else {
      $context['sandbox']['max'] = 1;
    }
  }

  // In case of multiple values data
  $data_entity = $data;
  if (isset($data['values'])) {
    $data_entity['values'][0] = $data['values'][$context['sandbox']['progress']];
  }
  _content_sync_entity_to_db($data_entity, '', $context);
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}