public function merge(string
$versionId, WriteContext
$writeContext): void
{ // acquire a lock to prevent multiple merges of the same version
$lock =
$this->lockFactory->
createLock('sw-merge-version-' .
$versionId);
if (!
$lock->
acquire()) { throw DataAbstractionLayerException::
versionMergeAlreadyLocked($versionId);
} // load all commits of the provided version
$commits =
$this->
getCommits($versionId,
$writeContext);
// create context for live and version
$versionContext =
$writeContext->
createWithVersionId($versionId);
$liveContext =
$writeContext->
createWithVersionId(Defaults::LIVE_VERSION
);
$versionContext->
addState(self::MERGE_SCOPE
);
$liveContext->
addState(self::MERGE_SCOPE
);
// group all payloads by their action (insert, update, delete) and by their entity name
$writes =
$this->
buildWrites($commits);