You are here

function entity_legal_update_7001 in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 entity_legal.install \entity_legal_update_7001()

Re-name legal entities in Field API, for users of 1.0.

File

./entity_legal.install, line 248
Install, update and uninstall functions for the entity_legal module.

Code

function entity_legal_update_7001() {

  // Update field config.
  $configs = db_select('field_config', 'f')
    ->fields('f')
    ->condition('field_name', 'entity_legal_document_text')
    ->execute()
    ->fetchAllAssoc('id');
  foreach ($configs as $config) {
    $config->data = unserialize($config->data);
    $config->data['entity_types'][0] = ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME;
    $config->data = serialize($config->data);
    db_update('field_config')
      ->condition('id', $config->id)
      ->fields((array) $config)
      ->execute();
  }

  // Update config instances.
  db_update('field_config_instance')
    ->condition('entity_type', 'legal_document_version')
    ->fields(array(
    'entity_type' => ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME,
  ))
    ->execute();

  // Update field data.
  db_update('field_data_entity_legal_document_text')
    ->condition('entity_type', 'legal_document_version')
    ->fields(array(
    'entity_type' => ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME,
  ))
    ->execute();

  // Update field revision data.
  db_update('field_revision_entity_legal_document_text')
    ->condition('entity_type', 'legal_document_version')
    ->fields(array(
    'entity_type' => ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME,
  ))
    ->execute();
  cache_clear_all();
}