public function ConflictResolverManager::resolveConflicts in Conflict 8.2
Resolves the conflicts between two entities based on their common parent.
Parameters
\Drupal\Core\Entity\EntityInterface $local: The local part of the comparision - for example the entity built of the user input on an entity form submission. This is basically the active entity object.
\Drupal\Core\Entity\EntityInterface $remote: The remote part of the comparision - for example the current version of the entity from the storage or from a remote branch.
\Drupal\Core\Entity\EntityInterface $base: The initial entity version in concurrent editing or the lowest common ancestor in a revision tree scenario.
\Drupal\Core\Entity\EntityInterface $result: (optional) The result entity, on which to apply the result. Usually this will be the active entity object - the local entity. If none given, then the conflict resolutions will be applied on the local entity.
\Symfony\Component\HttpFoundation\ParameterBag $context: (optional) The context parameter bag.
array $conflicts: (optional) The conflicts as returned by ::getConflicts() or a sub-set of them in order to limit the conflict resolution only to certain conflicts. If none conflicts are provided then a conflict detection will be performed.
Return value
array An associative array keyed by the conflicting properties, having as values the corresponding conflict type.
Overrides ConflictResolverManagerInterface::resolveConflicts
File
- src/
ConflictResolver/ ConflictResolverManager.php, line 37
Class
- ConflictResolverManager
- Manages conflict resolving.
Namespace
Drupal\conflict\ConflictResolverCode
public function resolveConflicts(EntityInterface $local, EntityInterface $remote, EntityInterface $base, EntityInterface $result = NULL, ParameterBag $context = NULL, array $conflicts = NULL) : array {
// If none conflicts are given, then explicitly discover the conflicts.
$conflicts = $conflicts ?? $this
->getConflicts($local, $remote, $base, $context);
if ($conflicts) {
$result = $result ?? $local;
$event = new EntityConflictResolutionEvent($local, $remote, $base, $result, $conflicts, $context);
// Fire an event to allow listeners to automatically resolve conflicts.
$this->eventDispatcher
->dispatch(EntityConflictEvents::ENTITY_CONFLICT_RESOLVE, $event);
$conflicts = $event
->getConflicts();
}
return $conflicts;
}