function eck_revision_batch_operation_create_entity_revisions in ECK Revision 7
1 string reference to 'eck_revision_batch_operation_create_entity_revisions'
File
- ./
eck_revision.module, line 327 - ECK Revision module.
Code
function eck_revision_batch_operation_create_entity_revisions($entity_type, $entity, $field_tables, $operation_details, &$context) {
// Get the entity label.
$title = $entity->title;
// Remove revision_id field because it will get populated
// when adding the record to the database.
unset($entity->revision_id);
// Copy base table data to revision table.
drupal_write_record("eck_" . $entity_type . "_revision", $entity);
// Set the revision id to the base table entry.
if (drupal_write_record("eck_" . $entity_type, $entity, 'id')) {
// Make sure the $entity->revision_id has been set before looping.
// Set new revision ID every fields of this entity.
foreach ($field_tables[$entity->type] as $table) {
$num_update = db_update($table)
->fields(array(
'revision_id' => $entity->revision_id,
))
->condition('entity_type', $entity_type, '=')
->condition('bundle', $entity->type, '=')
->condition('entity_id', $entity->id, '=')
->condition('revision_id', $entity->id, '=')
->execute();
}
}
// Set batch data.
$context['results'][] = $entity->id . ' : ' . check_plain($title);
$context['message'] = t('Creating revision data for "@title"', array(
'@title' => $title,
)) . ' ' . $operation_details;
}