You are here

private function DefaultFieldComparator::getComparableProperties in Changed Fields API 8.3

Same name and namespace in other branches
  1. 8 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

Drupal\Core\Field\FieldDefinitionInterface $field_definition: Field definition instance.

Return value

array Array of property names to compare field values on.

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 26

Class

DefaultFieldComparator
Provides default field comparator plugin definition.

Namespace

Drupal\changed_fields\Plugin\FieldComparator

Code

private function getComparableProperties(FieldDefinitionInterface $field_definition) {
  switch ($field_definition
    ->getType()) {
    case 'string':
    case 'string_long':
    case 'text':
    case 'text_long':
    case 'boolean':
    case 'integer':
    case 'float':
    case 'decimal':
    case 'datetime':
    case 'email':
    case 'password':
    case 'list_integer':
    case 'list_float':
    case 'list_string':
    case 'telephone':
      $properties = [
        'value',
      ];
      break;
    case 'text_with_summary':
      $properties = [
        'value',
        'summary',
      ];
      break;
    case 'entity_reference':
      $properties = [
        'target_id',
      ];
      break;
    case 'entity_reference_revisions':
      $properties = [
        'target_id',
        'target_revision_id',
      ];
      break;
    case 'file':
      $properties = [
        'target_id',
      ];
      if ($field_definition
        ->getSetting('description_field')) {
        $properties[] = 'description';
      }
      break;
    case 'image':
      $properties = [
        'width',
        'height',
        'target_id',
      ];
      if ($field_definition
        ->getSetting('alt_field')) {
        $properties[] = 'alt';
      }
      if ($field_definition
        ->getSetting('title_field')) {
        $properties[] = 'title';
      }
      break;
    case 'link':
      $properties = [
        'uri',
        'title',
      ];
      break;
    case 'daterange':
      $properties = [
        'value',
        'end_value',
      ];
      break;
    default:
      $properties = $this
        ->getDefaultComparableProperties($field_definition);
      break;
  }
  return $this
    ->extendComparableProperties($field_definition, $properties);
}