You are here

protected function ContentEntityStorageTrait::trackConflicts in Multiversion 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Storage/ContentEntityStorageTrait.php \Drupal\multiversion\Entity\Storage\ContentEntityStorageTrait::trackConflicts()

Uses the Conflict Tracker service to track conflicts for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to track for which to track conflicts.

1 call to ContentEntityStorageTrait::trackConflicts()
ContentEntityStorageTrait::save in src/Entity/Storage/ContentEntityStorageTrait.php

File

src/Entity/Storage/ContentEntityStorageTrait.php, line 604

Class

ContentEntityStorageTrait

Namespace

Drupal\multiversion\Entity\Storage

Code

protected function trackConflicts(EntityInterface $entity) {
  $workspace = isset($entity->workspace) ? $entity->workspace->entity : null;

  /** @var \Drupal\multiversion\Workspace\ConflictTrackerInterface $conflictTracker */
  $conflictTracker = \Drupal::service('workspace.conflict_tracker')
    ->useWorkspace($workspace);
  $index_factory = \Drupal::service('multiversion.entity_index.factory');

  /** @var \Drupal\multiversion\Entity\Index\RevisionTreeIndexInterface $tree */
  $tree = $index_factory
    ->get('multiversion.entity_index.rev.tree', $workspace);
  $conflicts = $tree
    ->getConflicts($entity
    ->uuid());
  if ($conflicts) {
    $conflictTracker
      ->add($entity
      ->uuid(), $conflicts, TRUE);
  }
  else {
    $conflictTracker
      ->resolveAll($entity
      ->uuid());
  }
}