protected function ContentEntityConflictHandler::needsMerge in Conflict 8.2
Performs a check if a merge is required.
Note that if the entity doesn't implement the EntityChangedInterface and no extended check ($extended_check = FALSE) is performed, then the method will return TRUE as there is no short way of checking for changes, in which case the extended check should be performed afterwards.
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.
bool $extended_check: Specifies whether an extended check should be performed.
Return value
bool TRUE if a merge is needed, FALSE otherwise.
1 call to ContentEntityConflictHandler::needsMerge()
- ContentEntityConflictHandler::entityFormEntityBuilder in src/
Entity/ ContentEntityConflictHandler.php - Entity builder method.
File
- src/
Entity/ ContentEntityConflictHandler.php, line 350
Class
Namespace
Drupal\conflict\EntityCode
protected function needsMerge(ContentEntityInterface $entity_local_edited, ContentEntityInterface $entity_local_original, ContentEntityInterface $entity_server, $extended_check) {
if ($this->entityType
->isRevisionable()) {
if ($entity_local_edited
->getRevisionId() != $entity_server
->getRevisionId() || $entity_local_edited
->getLoadedRevisionId() != $entity_server
->getLoadedRevisionId()) {
return TRUE;
}
}
if ($extended_check) {
return $this
->hasConflicts($entity_local_edited, $entity_local_original, $entity_server);
}
else {
$entity_server_langcodes = array_keys($entity_server
->getTranslationLanguages());
$entity_local_edited_langcodes = array_keys($entity_local_edited
->getTranslationLanguages());
if ($entity_server_langcodes != $entity_local_edited_langcodes) {
return TRUE;
}
if ($entity_local_edited instanceof EntityChangedInterface) {
foreach ($entity_server_langcodes as $langcode) {
/** @var \Drupal\Core\Entity\EntityChangedInterface $entity_server_translation */
$entity_server_translation = $entity_server
->getTranslation($langcode);
/** @var \Drupal\Core\Entity\EntityChangedInterface $entity_local_edited_translation */
$entity_local_edited_translation = $entity_local_edited
->getTranslation($langcode);
if ($entity_server_translation
->getChangedTime() != $entity_local_edited_translation
->getChangedTime()) {
return TRUE;
}
}
}
else {
// If the entity doesn't implement the EntityChangedInterface and a
// non-extended check is performed then we return TRUE, so that
// auto-merge is executed and an extended check is made afterwards.
return TRUE;
}
}
return FALSE;
}