Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / entity_insert.twig
1 /**
2  * Implements hook_entity_insert().
3  */
4 function {{ machine_name }}_entity_insert($entity, $type) {
5   // Insert the new entity into a fictional table of all entities.
6   $info = entity_get_info($type);
7   list($id) = entity_extract_ids($type, $entity);
8   db_insert('example_entity')
9     ->fields(array(
10       'type' => $type,
11       'id' => $id,
12       'created' => REQUEST_TIME,
13       'updated' => REQUEST_TIME,
14     ))
15     ->execute();
16 }