You are here

function hook_ENTITY_TYPE_insert in Entity API 7

Act on entities when inserted.

Parameters

$entity: The entity object.

See also

hook_entity_insert()

3 functions implement hook_ENTITY_TYPE_insert()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_test_entity_insert in tests/entity_test.module
Implements hook_entity_insert().
entity_test_entity_test_type_insert in tests/entity_test.module
Implements hook_entity_test_type_insert().
entity_test_i18n_entity_test_type_insert in tests/entity_test_i18n.module
Implements hook_{entity_test_type}_insert().

File

./entity.api.php, line 503
Hooks provided by the entity API.

Code

function hook_ENTITY_TYPE_insert($entity) {

  // Insert the new entity into a fictional table of all entities.
  list($id) = entity_extract_ids($type, $entity);
  db_insert('example_entity')
    ->fields(array(
    'type' => $type,
    'id' => $id,
    'created' => REQUEST_TIME,
    'updated' => REQUEST_TIME,
  ))
    ->execute();
}