You are here

function track_field_changes_entity_insert in Track Field Changes 8

Implements hook_entity_insert().

File

./track_field_changes.module, line 17

Code

function track_field_changes_entity_insert(\Drupal\Core\Entity\EntityInterface $entity) {
  $field_change_settings = \Drupal::config('track_field_changes.settings')
    ->get($entity
    ->getEntityTypeId() . '.' . $entity
    ->bundle());

  // If entity is audited.
  if (!empty($field_change_settings)) {

    // Get log.
    $log = isset($entity->track_field_changes) ? $entity->track_field_changes : '';
    if (!empty($field_change_settings['basic_new']) && !empty($log)) {
      track_field_changes_insert_db($entity
        ->getEntityTypeId(), $entity
        ->id(), 'log', '', '', 'bn', $log);
    }
  }
}