You are here

public function FieldComparatorDefault::getConflictType in Conflict 8.2

Returns the conflict type for a field.

Parameters

\Drupal\Core\Field\FieldItemListInterface $local: The local field item list to compare.

\Drupal\Core\Field\FieldItemListInterface $server: The server field item list to compare.

\Drupal\Core\Field\FieldItemListInterface $original: The original field item list, from which local and the server emerged.

string $langcode: The language code of the entity translation being checked.

string $entity_type_id: The entity type ID.

string $bundle: The entity bundle ID.

string $field_type: The field type.

string $field_name: The field name.

Return value

string|null The conflict type or NULL if none.

Throws

\Exception An exception will be thrown if for some reason even the default field comparator has not been added to the field comparators list.

Overrides FieldComparatorInterface::getConflictType

1 call to FieldComparatorDefault::getConflictType()
FieldComparatorParagraphReference::getConflictType in modules/conflict_paragraphs/src/Plugin/Conflict/FieldComparator/FieldComparatorParagraphReference.php
Returns the conflict type for a field.
1 method overrides FieldComparatorDefault::getConflictType()
FieldComparatorParagraphReference::getConflictType in modules/conflict_paragraphs/src/Plugin/Conflict/FieldComparator/FieldComparatorParagraphReference.php
Returns the conflict type for a field.

File

src/Plugin/Conflict/FieldComparator/FieldComparatorDefault.php, line 35

Class

FieldComparatorDefault
Default field comparator plugin implementation covering all fields.

Namespace

Drupal\conflict\Plugin\Conflict\FieldComparator

Code

public function getConflictType(FieldItemListInterface $local, FieldItemListInterface $server, FieldItemListInterface $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) {

  // Check for changes between the server and the locally edited version.
  if ($this
    ->hasChanged($server, $local, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {

    // Check for changes between the server and the locally used original
    // version.
    if ($this
      ->hasChanged($server, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {

      // Check for changes between the locally edited and locally used
      // original version.
      $conflict_type = $this
        ->hasChanged($local, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) ? ConflictTypes::CONFLICT_TYPE_LOCAL_REMOTE : ConflictTypes::CONFLICT_TYPE_REMOTE;
      return $conflict_type;
    }
  }
  return NULL;
}