1. drupal
    1. 8 entity.module
    2. 7
8 – 7 entity_extract_ids($entity_type, $entity)

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


$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

▾ 39 functions call entity_extract_ids()

entity_form_submit_build_entity in includes/common.inc
Helper function for copying submitted values to entity properties for simple entity forms.
entity_uri in includes/common.inc
Returns the uri elements of an entity.
FieldBulkDeleteTestCase::_generateStubEntities in modules/field/tests/field.test
Convenience function for Field API tests.
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
Loads fields for the current revisions of a group of entities.
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 one field on one entity instance.
field_language in modules/field/field.multilingual.inc
Returns the display language for the fields attached to the given entity.
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_delete_revision in modules/file/file.field.inc
Implements hook_field_delete_revision().
file_field_insert in modules/file/file.field.inc
Implements hook_field_insert().
file_field_update in modules/file/file.field.inc
Implements hook_field_update().
hook_entity_delete in modules/system/system.api.php
Act on entities when deleted.
hook_entity_insert in modules/system/system.api.php
Act on entities when inserted.
hook_entity_update in modules/system/system.api.php
Act on entities when updated.
hook_field_delete in modules/field/field.api.php
Define custom delete behavior for this module's field types.
hook_field_storage_delete in modules/field/field.api.php
Delete all field data for an entity.
hook_field_storage_delete_revision in modules/field/field.api.php
Delete a single revision of field data for an entity.
hook_field_storage_purge in modules/field/field.api.php
Remove field storage information when field data is purged.
hook_field_storage_write in modules/field/field.api.php
Write field data for an entity.
locale_field_node_form_submit in modules/locale/locale.module
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.


includes/common.inc, line 7383

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['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
  $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;

  if (!empty($info['entity keys']['bundle'])) {
    // Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    $bundle = $entity->{$info['entity keys']['bundle']};
  else {
    // The entity type provides no bundle key: assume a single bundle, named
    // after the entity type.
    $bundle = $entity_type;

  return array($id, $vid, $bundle);