You are here

class MergeRemoteOnlyChanges in Conflict 8.2

Hierarchy

Expanded class hierarchy of MergeRemoteOnlyChanges

1 string reference to 'MergeRemoteOnlyChanges'
conflict.services.yml in ./conflict.services.yml
conflict.services.yml
1 service uses MergeRemoteOnlyChanges
conflict_resolution.merge_remote_only_changes in ./conflict.services.yml
\Drupal\conflict\ConflictResolution\MergeRemoteOnlyChanges

File

src/ConflictResolution/MergeRemoteOnlyChanges.php, line 8

Namespace

Drupal\conflict\ConflictResolution
View source
class MergeRemoteOnlyChanges extends MergeStrategyBase {

  /**
   * {@inheritdoc}
   */
  public function getMergeStrategyId() : string {
    return 'conflict.merge_remote_only_changes';
  }

  /**
   * {@inheritdoc}
   */
  public function resolveConflictsContentEntity(EntityConflictResolutionEvent $event) {

    /** @var \Drupal\Core\Entity\ContentEntityInterface $remote_entity */
    $remote_entity = $event
      ->getRemoteEntity();

    /** @var \Drupal\Core\Entity\ContentEntityInterface $result_entity */
    $result_entity = $event
      ->getResultEntity();
    foreach ($event
      ->getConflicts() as $property => $conflict_type) {
      if ($conflict_type === ConflictTypes::CONFLICT_TYPE_REMOTE) {
        $result_entity
          ->set($property, $remote_entity
          ->get($property)
          ->getValue());
        $event
          ->removeConflict($property);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MergeRemoteOnlyChanges::getMergeStrategyId public function Returns the merge strategy ID. Overrides MergeStrategyInterface::getMergeStrategyId
MergeRemoteOnlyChanges::resolveConflictsContentEntity public function Resolves conflicts on content entities. Overrides MergeStrategyInterface::resolveConflictsContentEntity
MergeStrategyBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
MergeStrategyBase::isEnabled public function Checks whether this merge strategy is active for the conflict resolution. Overrides MergeStrategyInterface::isEnabled
MergeStrategyBase::resolveConflicts public function Discovers conflicts on entities.