You are here

public function ReplicatorManager::update in Workspace 8

Update the target using the source before doing a replication.

This is used primarily as a public facing method by the UpdateForm. It avoids the additional logic found in the replicate method.

Parameters

\Drupal\workspace\WorkspacePointerInterface $target: The workspace to replicate to.

\Drupal\workspace\WorkspacePointerInterface $source: The workspace to replicate from.

mixed $task: Optional information that defines the replication task to perform.

Return value

\Drupal\replication\Entity\ReplicationLogInterface The log entry for this replication.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to ReplicatorManager::update()
ReplicatorManager::replicate in src/ReplicatorManager.php
Perform the replication from the source to target workspace.

File

src/ReplicatorManager.php, line 202

Class

ReplicatorManager
Provides the Replicator manager.

Namespace

Drupal\workspace

Code

public function update(WorkspacePointerInterface $target, WorkspacePointerInterface $source, $task = NULL) {

  // Create replication entity.
  // For an update (pull) the source and target are reversed.
  $replication = Replication::create([
    'name' => t('Update from @source to @target', [
      '@source' => $target
        ->label(),
      '@target' => $source
        ->label(),
    ]),
    'source' => $target,
    'target' => $source,
  ]);
  if ($task && is_array($task
    ->getDocIds())) {
    $replication
      ->setDocIds($task
      ->getDocIds());
  }
  $this
    ->queueReplication($replication, $task);
  return $this
    ->replicationLog($target, $source, $task, TRUE);
}