diff --git a/src/EventSubscriber/WorkbenchModerationSubscriber.php b/src/EventSubscriber/WorkbenchModerationSubscriber.php index 603b44a..495e865 100644 --- a/src/EventSubscriber/WorkbenchModerationSubscriber.php +++ b/src/EventSubscriber/WorkbenchModerationSubscriber.php @@ -92,7 +92,24 @@ class WorkbenchModerationSubscriber implements EventSubscriberInterface { // Derive a replication task from the Workspace we are acting on. $task = $this->replicatorManager->getTask($workspace, 'push_replication_settings'); - $this->replicatorManager->replicate($source_pointer, $parent_workspace_pointer, $task); + /** @var \Drupal\replication\Entity\ReplicationLogInterface $log */ + $log = $this->replicatorManager->replicate($source_pointer, $parent_workspace_pointer, $task); + + // Display a message to the user on what happened. + if ($log->get('ok')) { + drupal_set_message(t('Changes in :source were replicated to :target.', [ + ':source' => $workspace->label(), + ':target' => $workspace->get('upstream')->entity->label(), + ]), 'status'); + } + else { + // @todo Where do we get more info about why it failed? Should we add a + // description field to the replication log? + drupal_set_message(t('Publishing the :source workspace failed!', [ + ':source' => $workspace->label(), + ':target' => $workspace->get('upstream')->entity->label(), + ]), 'error'); + } } /** diff --git a/src/ReplicatorManager.php b/src/ReplicatorManager.php index 9a82d7e..c53779a 100644 --- a/src/ReplicatorManager.php +++ b/src/ReplicatorManager.php @@ -60,10 +60,15 @@ class ReplicatorManager implements ReplicatorInterface { * {@inheritdoc} */ public function replicate(WorkspacePointerInterface $source, WorkspacePointerInterface $target, ReplicationTaskInterface $task = NULL) { + // It is assumed a caller of replicate will set this static variable to + // FALSE if they wish to proceed with replicating content upstream even in + // the presence of conflicts. + // @todo Use a sequence index instead of boolean? This will allow the + // caller to know there haven't been additional conflicts. $is_aborted_on_conflict = drupal_static('workspace_is_aborted_on_conflict', TRUE); // Abort updating the Workspace if there are conflicts. - $initial_conflicts = $this->conflictTracker->getAll(); + $initial_conflicts = $this->conflictTracker->useWorkspace($source->getWorkspace())->getAll(); if ($is_aborted_on_conflict && $initial_conflicts) { return $this->failedReplicationLog($source, $target, $task); } @@ -75,7 +80,7 @@ class ReplicatorManager implements ReplicatorInterface { $this->update($target, $source, $pull_task); // Abort replicating to target Workspace if there are conflicts. - $post_conflicts = $this->conflictTracker->getAll(); + $post_conflicts = $this->conflictTracker->useWorkspace($source->getWorkspace())->getAll(); if ($is_aborted_on_conflict && $post_conflicts) { return $this->failedReplicationLog($source, $target, $task); }