You are here

private function DefaultFieldComparator::getComparableProperties in Changed Fields API 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/FieldComparator/DefaultFieldComparator.php \Drupal\changed_fields\Plugin\FieldComparator\DefaultFieldComparator::getComparableProperties()
  2. 8.2 src/Plugin/FieldComparator/DefaultFieldComparator.php \Drupal\changed_fields\Plugin\FieldComparator\DefaultFieldComparator::getComparableProperties()

Method that returns comparable properties for existing field type.

Parameters

FieldDefinitionInterface $fieldDefinition:

Return value

array

1 call to DefaultFieldComparator::getComparableProperties()
DefaultFieldComparator::compareFieldValues in src/Plugin/FieldComparator/DefaultFieldComparator.php
Method that compares old and new field values.

File

src/Plugin/FieldComparator/DefaultFieldComparator.php, line 27
Contains DefaultFieldComparator.php.

Class

DefaultFieldComparator
Plugin annotation @Plugin( id = "default_field_comparator" )

Namespace

Drupal\changed_fields\Plugin\FieldComparator

Code

private function getComparableProperties(FieldDefinitionInterface $fieldDefinition) {
  switch ($fieldDefinition
    ->getType()) {
    case 'string':
    case 'string_long':
    case 'text':
    case 'text_long':
    case 'boolean':
    case 'integer':
    case 'float':
    case 'decimal':
    case 'datetime':
    case 'email':
    case 'list_integer':
    case 'list_float':
    case 'list_string':
    case 'telephone':
      $properties = array(
        'value',
      );
      break;
    case 'text_with_summary':
      $properties = array(
        'value',
        'summary',
      );
      break;
    case 'entity_reference':
      $properties = array(
        'target_id',
      );
      break;
    case 'file':
      $properties = array(
        'target_id',
        'description',
      );
      break;
    case 'image':
      $properties = array(
        'fid',
        'width',
        'height',
        'target_id',
        'alt',
        'title',
      );
      break;
    case 'link':
      $properties = array(
        'uri',
        'title',
      );
      break;
    default:
      $properties = $this
        ->getDefaultComparableProperties($fieldDefinition);
      break;
  }
  return $properties;
}