You are here

private function CFDefaultFieldComparator::getComparableProperties in Changed Fields API 7.2

Same name and namespace in other branches
  1. 7.3 src/FieldComparator/CFDefaultFieldComparator.php \CFDefaultFieldComparator::getComparableProperties()
  2. 7 includes/changed_fields.core.inc \CFDefaultFieldComparator::getComparableProperties()

Method that returns comparable properties for existing field type.

Parameters

array $fieldInfo: Array contains field instance and field base information.

Return value

array Array with properties that we need to use to compare two field values.

1 call to CFDefaultFieldComparator::getComparableProperties()
CFDefaultFieldComparator::compareFieldValues in includes/changed_fields.core.inc
Method that compares old and new field values.

File

includes/changed_fields.core.inc, line 303
File contains core classes and interfaces.

Class

CFDefaultFieldComparator
Class CFDefaultFieldComparator.

Code

private function getComparableProperties(array $fieldInfo) {
  switch ($fieldInfo['field_base']['type']) {
    case 'text_with_summary':
      $properties = array(
        'value',
        'summary',
        'format',
      );
      break;
    case 'text':
    case 'text_long':
    case 'number_decimal':
    case 'number_float':
    case 'number_integer':
    case 'list_float':
    case 'list_integer':
    case 'list_boolean':
    case 'list_text':
    case 'phone':
      $properties = array(
        'value',
      );
      break;
    case 'taxonomy_term_reference':
      $properties = array(
        'tid',
      );
      break;
    case 'entityreference':
      $properties = array(
        'target_id',
      );
      break;
    case 'image':
      $properties = array(
        'fid',
        'width',
        'height',
      );
      if (!empty($fieldInfo['field_instance']['settings']['alt_field'])) {
        $properties[] = 'alt';
      }
      if (!empty($fieldInfo['field_instance']['settings']['title_field'])) {
        $properties[] = 'title';
      }
      break;
    case 'file':
      $properties = array(
        'fid',
      );
      if (!empty($fieldInfo['field_instance']['settings']['description_field'])) {
        $properties[] = 'description';
      }
      if (!empty($fieldInfo['field_instance']['settings']['display_field'])) {
        $properties[] = 'display';
      }
      break;
    case 'date':
    case 'datetime':
    case 'datestamp':
      $properties = array(
        'value',
        'timezone',
      );
      break;
    case 'email':
      $properties = array(
        'email',
      );
      break;
    case 'link_field':
      $properties = array(
        'url',
        'title',
      );
      break;
    default:
      $properties = $this
        ->getDefaultComparableProperties($fieldInfo);
      break;
  }
  return $this
    ->extendComparableProperties($fieldInfo, $properties);
}