View source
<?php
namespace Drupal\conflict\Plugin\Conflict\FieldComparator;
use Drupal\conflict\ConflictTypes;
use Drupal\conflict\FieldComparatorInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Plugin\PluginBase;
class FieldComparatorDefault extends PluginBase implements FieldComparatorInterface {
public function hasChanged(FieldItemListInterface $field_item_list_a, FieldItemListInterface $field_item_list_b, $langcode = NULL, $entity_type_id = NULL, $bundle = NULL, $field_type = NULL, $field_name = NULL) {
$equals = $field_item_list_a
->equals($field_item_list_b);
return !$equals;
}
public function getConflictType(FieldItemListInterface $local, FieldItemListInterface $server, FieldItemListInterface $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) {
if ($this
->hasChanged($server, $local, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {
if ($this
->hasChanged($server, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name)) {
$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;
}
public static function isApplicable(FieldDefinitionInterface $field_definition) {
return TRUE;
}
}