protected function ContentEntityConflictHandler::hasConflicts in Conflict 8.2
Checks whether there are conflicts.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity_local_edited: The locally edited entity.
\Drupal\Core\Entity\ContentEntityInterface $entity_local_original: The original not edited entity used to build the form.
\Drupal\Core\Entity\ContentEntityInterface $entity_server: The unchanged entity loaded from the storage.
Return value
bool
1 call to ContentEntityConflictHandler::hasConflicts()
- ContentEntityConflictHandler::needsMerge in src/
Entity/ ContentEntityConflictHandler.php - Performs a check if a merge is required.
File
- src/
Entity/ ContentEntityConflictHandler.php, line 556
Class
Namespace
Drupal\conflict\EntityCode
protected function hasConflicts(ContentEntityInterface $entity_local_edited, ContentEntityInterface $entity_local_original, ContentEntityInterface $entity_server) {
$entity_type_id = $this->entityType
->id();
$entity_bundle = $entity_local_edited
->bundle();
$langcode = $entity_local_edited
->language()
->getId();
$entity_server = $entity_server
->getTranslation($langcode);
$entity_local_original = $entity_local_original
->getTranslation($langcode);
$skip_fields = [];
// The revision created field is updated constantly and it will always cause
// conflicts, therefore we skip it here, as it gets updated correctly on
// submit during entity building from user input.
// @see \Drupal\Core\Entity\ContentEntityForm::buildEntity().
$skip_fields = array_flip($this->entityType
->getRevisionMetadataKeys());
foreach ($entity_local_edited
->getFields() as $field_name => $field_items_list_local_edited) {
if (isset($skip_fields[$field_name])) {
continue;
}
$field_definition = $field_items_list_local_edited
->getFieldDefinition();
// There could be no conflicts in read only fields.
if ($field_definition
->isReadOnly()) {
continue;
}
$field_type = $field_definition
->getType();
$field_items_list_server = $entity_server
->get($field_name);
$field_items_list_local_original = $entity_local_original
->get($field_name);
// Check for changes between the server and the locally edited version. If
// there are no changes between them then it might happen that a field
// is changed in both versions to the same value, which we do not
// consider as any conflict.
if ($this->fieldComparatorManager
->hasChanged($field_items_list_server, $field_items_list_local_edited, $langcode, $entity_type_id, $entity_bundle, $field_type, $field_name)) {
// Check for changes between the server the locally used original
// version. If the server version has changed compared to the locally
// used original version then there is a conflict either
// - value changed only on the server
// - value changed both on the server and locally
if ($this->fieldComparatorManager
->hasChanged($field_items_list_server, $field_items_list_local_original, $langcode, $entity_type_id, $entity_bundle, $field_type, $field_name)) {
return TRUE;
}
}
}
return FALSE;
}