entity_extract_ids

Versions
mediamosa-21
entity_extract_ids($entity_type, $entity)

Helper function to extract id, vid, and bundle name from an entity.

Parameters

$entity_type The entity type; e.g. 'node' or 'user'.

$entity The entity from which to extract values.

Return value

A numerically indexed array (not a hash table) containing these elements: 0: primary id of the entity 1: revision id of the entity, or NULL if $entity_type is not versioned 2: bundle name of the entity 3: whether $entity_type's fields should be cached (TRUE/FALSE)

▾ 26 functions call entity_extract_ids()

field_attach_delete in modules/field/field.attach.inc
Delete field data for an existing entity. This deletes all revisions of field data for the entity.
field_attach_delete_revision in modules/field/field.attach.inc
Delete field data for a single revision of an existing entity. The passed entity must have a revision id attribute.
field_attach_form in modules/field/field.attach.inc
Add form elements for all fields for an entity to a form structure.
field_attach_insert in modules/field/field.attach.inc
Save field data for a new entity.
field_attach_load in modules/field/field.attach.inc
Load all fields for the most current version of each of a set of entities of a single entity type.
field_attach_preprocess in modules/field/field.attach.inc
Populate the template variables with the field values available for rendering.
field_attach_update in modules/field/field.attach.inc
Save field data for an existing entity.
field_attach_view in modules/field/field.attach.inc
Returns a renderable array for the fields on an entity.
field_default_form in modules/field/field.form.inc
Create a separate form element for each field.
field_default_view in modules/field/field.default.inc
Builds a renderable array for field values.
field_sql_storage_field_storage_delete in modules/field/modules/field_sql_storage/field_sql_storage.module
Implements hook_field_storage_delete().
field_sql_storage_field_storage_delete_revision in modules/field/modules/field_sql_storage/field_sql_storage.module
Implements hook_field_storage_delete_revision().
field_sql_storage_field_storage_purge in modules/field/modules/field_sql_storage/field_sql_storage.module
Implements hook_field_storage_purge().
field_sql_storage_field_storage_write in modules/field/modules/field_sql_storage/field_sql_storage.module
Implements hook_field_storage_write().
field_test_field_storage_delete in modules/field/tests/field_test.storage.inc
Implements hook_field_storage_delete().
field_test_field_storage_delete_revision in modules/field/tests/field_test.storage.inc
Implements hook_field_storage_delete_revision().
field_test_field_storage_purge in modules/field/tests/field_test.storage.inc
Implements hook_field_storage_purge().
field_test_field_storage_write in modules/field/tests/field_test.storage.inc
Implements hook_field_storage_write().
field_view_field in modules/field/field.module
Returns a renderable array for the value of a single field in an entity.
file_field_delete in modules/file/file.field.inc
Implements hook_field_delete().
file_field_update in modules/file/file.field.inc
Implements hook_field_update().
locale_field_fallback_view in modules/locale/locale.field.inc
Apply fallback rules to the given object.
locale_field_node_form_update_field_language in modules/locale/locale.field.inc
Form submit handler for node_form().
rdf_entity_load in modules/rdf/rdf.module
Implements hook_entity_load().
_field_invoke in modules/field/field.attach.inc
Invoke a field hook.
_field_invoke_multiple in modules/field/field.attach.inc
Invoke a field hook across fields on multiple entities.

Code

includes/common.inc, line 6310

<?php
function entity_extract_ids($entity_type, $entity) {
  $info = entity_get_info($entity_type);
  // Objects being created might not have id/vid yet.
  $id = isset($entity->{$info['object keys']['id']}) ? $entity->{$info['object keys']['id']} : NULL;
  $vid = ($info['object keys']['revision'] && isset($entity->{$info['object keys']['revision']})) ? $entity->{$info['object keys']['revision']} : NULL;
  // If no bundle key provided, then we assume a single bundle, named after the
  // entity type.
  $bundle = $info['object keys']['bundle'] ? $entity->{$info['object keys']['bundle']} : $entity_type;
  $cacheable = $info['cacheable'];
  return array($id, $vid, $bundle, $cacheable);
}
?>