Act before the storage backends insert field data.
This hook allows modules to store data before the Field Storage API, optionally preventing the field storage module from doing so.
\Drupal\Core\Entity\EntityInterface $entity: The entity with fields to save.
$skip_fields: An array keyed by field UUIDs whose data has already been written and therefore should not be written again. The values associated with these keys are not specified.
Saved field UUIDs are set as keys in $skip_fields.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_field_storage_pre_insert(\Drupal\Core\Entity\EntityInterface $entity, &$skip_fields) {
if ($entity
->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
$query = db_insert('forum_index')
->fields(array(
'nid',
'title',
'tid',
'sticky',
'created',
'comment_count',
'last_comment_timestamp',
));
foreach ($entity->taxonomy_forums as $language) {
foreach ($language as $delta) {
$query
->values(array(
'nid' => $entity->nid,
'title' => $entity->title,
'tid' => $delta['value'],
'sticky' => $entity->sticky,
'created' => $entity->created,
'comment_count' => 0,
'last_comment_timestamp' => $entity->created,
));
}
}
$query
->execute();
}
}