| 7 system.api.php | hook_entity_insert($entity, $type) |
| 8 entity.api.php | hook_entity_insert($entity, $type) |
Act on entities when inserted.
Parameters
$entity: The entity object.
$type: The type of entity being inserted (i.e. node, user, comment).
Related topics
1 function implements hook_entity_insert()
4 invocations of hook_entity_insert()
File
- modules/
system/ system.api.php, line 307 - Hooks provided by Drupal core and the System module.
Code
function hook_entity_insert($entity, $type) {
// Insert the new entity into a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_insert('example_entity')
->fields(array(
'type' => $type,
'id' => $id,
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
))
->execute();
}
Login or register to post comments