You are here

function title_field_replacement_init in Title 7

Initialize a batch of replacing field values.

Parameters

$entity_type: The type of $entity.

$bundle: The bundle the legacy field belongs to.

$legacy_field: The name of the legacy field to be replaced.

$ids: An array of entity IDs.

Return value

The number of entities processed.

1 call to title_field_replacement_init()
title_field_replacement_batch in ./title.module
Batch operation: initialize a batch of replacing field values.

File

./title.module, line 408

Code

function title_field_replacement_init($entity_type, $bundle, $legacy_field, $ids) {
  $GLOBALS['title_field_replacement_init'] = TRUE;
  $entities = entity_load($entity_type, $ids);
  foreach ($entities as $id => $entity) {
    list(, , $entity_bundle) = entity_extract_ids($entity_type, $entity);
    if ($entity_bundle == $bundle) {
      field_attach_presave($entity_type, $entity);
      field_attach_update($entity_type, $entity);
    }
  }
  unset($GLOBALS['title_field_replacement_init']);
}