public function FieldComparatorManager::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 FieldComparatorManagerInterface::getConflictType
File
- src/
FieldComparatorManager.php, line 54
Class
Namespace
Drupal\conflictCode
public function getConflictType(FieldItemListInterface $local, FieldItemListInterface $server, FieldItemListInterface $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name) {
// Iterate from the most specific to the most general comparator.
foreach ($this
->getOrderedFieldComparators($entity_type_id, $bundle, $field_type, $field_name) as &$comparator) {
/** @var \Drupal\conflict\FieldComparatorInterface $comparator */
if (!is_object($comparator)) {
$comparator = $this
->createInstance($comparator);
}
if ($comparator::isApplicable($local
->getFieldDefinition())) {
$conflict_type = $comparator
->getConflictType($local, $server, $original, $langcode, $entity_type_id, $bundle, $field_type, $field_name);
if ($conflict_type) {
return $conflict_type;
}
}
}
return NULL;
}