You are here

function track_field_changes_is_empty in Track Field Changes 8

Same name and namespace in other branches
  1. 7 track_field_changes.module \track_field_changes_is_empty()

Compare if one field is empty.

return FALSE if not empty return TRUE if empty

File

./track_field_changes.module, line 279

Code

function track_field_changes_is_empty($field_info_type, $field) {
  if ($field_info_type == 'title') {
    return $field == '';
  }
  else {
    switch ($field_info_type) {
      case 'datestamp':
      case 'datetime':
      case 'date':
        return empty($field);
      case 'tablefield':
      case 'text_long':
      case 'list_text':
      case 'list_boolean':
      case 'text_with_summary':
      case 'number_decimal':
      case 'number_float':
      case 'text':
      case 'entityreference':
        $field = $field[\Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED];
        return empty($field);
      case 'email':
        return FALSE;
      case 'link_field':
        return FALSE;
      case 'image':
      case 'file':
        $field = $field[\Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED];
        return empty($field);
      case 'taxonomy_term_reference':
      case 'list_integer':
      case 'list_float':
      case 'number_integer':
      case 'user_reference':
      case 'geofield':
        return $field == '';
      default:
        return FALSE;
    }
  }
}