You are here

protected function ReplicatorManager::replicationLog in Workspace 8

Generate a failed replication log and return it.

Parameters

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

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

\Drupal\replication\ReplicationTask\ReplicationTaskInterface|null $task: The replication task.

bool $ok: True if the replication was started successfully, false otherwise.

Return value

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

Throws

\Drupal\Core\Entity\EntityStorageException

3 calls to ReplicatorManager::replicationLog()
ReplicatorManager::doReplication in src/ReplicatorManager.php
Internal method to contain replication logic.
ReplicatorManager::replicate in src/ReplicatorManager.php
Perform the replication from the source to target workspace.
ReplicatorManager::update in src/ReplicatorManager.php
Update the target using the source before doing a replication.

File

src/ReplicatorManager.php, line 280

Class

ReplicatorManager
Provides the Replicator manager.

Namespace

Drupal\workspace

Code

protected function replicationLog(WorkspacePointerInterface $source, WorkspacePointerInterface $target, ReplicationTaskInterface $task = NULL, $ok = FALSE) {
  $time = new \DateTime();
  $history = [
    'start_time' => $time
      ->format('D, d M Y H:i:s e'),
    'end_time' => $time
      ->format('D, d M Y H:i:s e'),
    'session_id' => \md5(\microtime(TRUE) * 1000000),
  ];
  $replication_log_id = $source
    ->generateReplicationId($target, $task);

  /** @var \Drupal\replication\Entity\ReplicationLogInterface $replication_log */
  $replication_log = ReplicationLog::loadOrCreate($replication_log_id);
  $replication_log
    ->set('ok', $ok);
  $replication_log
    ->setSessionId($history['session_id']);
  $replication_log
    ->setHistory($history);
  $replication_log
    ->save();
  return $replication_log;
}