You are here

public function WorkspacePointer::generateReplicationId in Workspace 8

Parameters

\Drupal\workspace\WorkspacePointerInterface $target:

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

Return value

string

Overrides WorkspacePointerInterface::generateReplicationId

See also

\Relaxed\Replicator\Replication::generateReplicationId()

File

src/Entity/WorkspacePointer.php, line 136

Class

WorkspacePointer
Defines the Workspace pointer entity.

Namespace

Drupal\workspace\Entity

Code

public function generateReplicationId(WorkspacePointerInterface $target, ReplicationTaskInterface $task = NULL) {
  $request = \Drupal::request();
  $uuid = MD5($request
    ->getHost() . $request
    ->getPort());
  $source_name = $this
    ->label();
  if ($this
    ->getWorkspace() instanceof WorkspaceInterface) {
    $source_name = $this
      ->getWorkspace()
      ->getMachineName();
  }
  $target_name = $target
    ->label();
  if ($target
    ->getWorkspace() instanceof WorkspaceInterface) {
    $target_name = $target
      ->getWorkspace()
      ->getMachineName();
  }
  if ($task) {
    return \md5($uuid . $source_name . $target_name . var_export($task
      ->getDocIds(), TRUE) . ($task
      ->getCreateTarget() ? '1' : '0') . ($task
      ->getContinuous() ? '1' : '0') . $task
      ->getFilter() . '' . $task
      ->getStyle() . var_export($task
      ->getHeartbeat(), TRUE));
  }
  return \md5($uuid . $source_name . $target_name);
}