Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_storage_pre_insert.twig
1 /**
2  * Implements hook_field_storage_pre_insert().
3  */
4 function {{ machine_name }}_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
5   if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
6     $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
7     foreach ($entity->taxonomy_forums as $language) {
8       foreach ($language as $delta) {
9         $query->values(array(
10           'nid' => $entity->nid,
11           'title' => $entity->title,
12           'tid' => $delta['value'],
13           'sticky' => $entity->sticky,
14           'created' => $entity->created,
15           'comment_count' => 0,
16           'last_comment_timestamp' => $entity->created,
17         ));
18       }
19     }
20     $query->execute();
21   }
22 }