You are here

function webform_localization_get_id_by_uuid in Webform Localization 7

Same name and namespace in other branches
  1. 7.4 includes/webform_localization.i18n.inc \webform_localization_get_id_by_uuid()

Helper function that retrieves entity IDs by their UUIDs.

Parameters

$entity_type: The entity type we should be dealing with.

$uuids: An array of UUIDs for which we should find their entity IDs. If $revision is TRUE this should be revision UUIDs instead.

Return value

Array of entity IDs keyed by their UUIDs. If $revision is TRUE revision IDs and UUIDs are returned instead.

1 call to webform_localization_get_id_by_uuid()
webform_localization_uuid_update_strings in includes/webform_localization.i18n.inc
Update i18n string contexts if uuid module is enabled/disabled.

File

includes/webform_localization.i18n.inc, line 471
Webform Localization i18n_string integration.

Code

function webform_localization_get_id_by_uuid($entity_type, $uuids) {
  if (empty($uuids)) {
    return array();
  }
  $info = entity_get_info($entity_type);
  $table = $info['base table'];
  $id_key = $info['entity keys']['id'];

  // The uuid key is not available at hook_disable.
  $core_info = uuid_get_core_entity_info();
  $uuid_key = $core_info['node']['entity keys']['uuid'];

  // Get all UUIDs in one query.
  return db_select($table, 't')
    ->fields('t', array(
    $uuid_key,
    $id_key,
  ))
    ->condition($uuid_key, array_values($uuids), 'IN')
    ->execute()
    ->fetchAllKeyed();
}