diff --git a/src/EventSubscriber/WorkbenchModerationSubscriber.php b/src/EventSubscriber/WorkbenchModerationSubscriber.php index 43f70ce..603b44a 100644 --- a/src/EventSubscriber/WorkbenchModerationSubscriber.php +++ b/src/EventSubscriber/WorkbenchModerationSubscriber.php @@ -4,7 +4,6 @@ namespace Drupal\workspace\EventSubscriber; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\multiversion\Entity\WorkspaceInterface; -use Drupal\workbench_moderation\Entity\ModerationState; use Drupal\workbench_moderation\Event\WorkbenchModerationEvents; use Drupal\workbench_moderation\Event\WorkbenchModerationTransitionEvent; use Drupal\workspace\ReplicatorManager; @@ -16,15 +15,27 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; class WorkbenchModerationSubscriber implements EventSubscriberInterface { /** + * The entity type manager to use for checking moderation information. + * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** + * The replicator manager to trigger replication on. + * * @var \Drupal\workspace\ReplicatorManager */ protected $replicatorManager; + /** + * Inject dependencies. + * + * @param EntityTypeManagerInterface $entity_type_manager + * The entity type manager to use for checking moderation information. + * @param ReplicatorManager $replicator_manager + * The replicator manager to trigger replication on. + */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ReplicatorManager $replicator_manager) { $this->entityTypeManager = $entity_type_manager; $this->replicatorManager = $replicator_manager; @@ -55,7 +66,7 @@ class WorkbenchModerationSubscriber implements EventSubscriberInterface { * TRUE if the event is moving an entity to a default-revision state. */ protected function wasDefaultRevision(WorkbenchModerationTransitionEvent $event) { - /** @var ModerationState $post_state */ + /** @var Drupal\workbench_moderation\Entity\ModerationState $post_state */ $post_state = $this->entityTypeManager->getStorage('moderation_state')->load($event->getStateAfter()); return $post_state->isPublishedState(); @@ -78,7 +89,7 @@ class WorkbenchModerationSubscriber implements EventSubscriberInterface { $source_pointer = $this->getPointerToWorkspace($workspace); - // Derive a replication task from the source Workspace. + // 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); diff --git a/src/Form/UpdateForm.php b/src/Form/UpdateForm.php index 728755a..df7035d 100644 --- a/src/Form/UpdateForm.php +++ b/src/Form/UpdateForm.php @@ -158,7 +158,7 @@ class UpdateForm extends ConfirmFormBase { $upstream = $this->getUpstream(); $active = $this->getActive(); try { - // Derive a replication task from the source Workspace. + // Derive a replication task from the Workspace we are acting on. $task = $this->replicatorManager->getTask($active->getWorkspace(), 'pull_replication_settings'); $response = $this->replicatorManager->update($upstream, $active, $task); diff --git a/src/ReplicatorManager.php b/src/ReplicatorManager.php index 273407b..15f5c1b 100644 --- a/src/ReplicatorManager.php +++ b/src/ReplicatorManager.php @@ -63,8 +63,8 @@ class ReplicatorManager implements ReplicatorInterface { // @todo use $initial_conflicts in a conflict management workflow $initial_conflicts = $this->conflictTracker->getAll(); - // Derive a replication task from the target Workspace for pulling. - $pull_task = $this->getTask($target->getWorkspace(), 'pull_replication_settings'); + // Derive a pull replication task from the Workspace we are acting on. + $pull_task = $this->getTask($source->getWorkspace(), 'pull_replication_settings'); // Pull in changes from $target to $source to ensure a merge will complete. $this->update($target, $source, $pull_task); @@ -76,8 +76,8 @@ class ReplicatorManager implements ReplicatorInterface { // @todo Refactor to eliminate obscurity of having an optional parameter // and automatically setting the parameter's value. if ($task === NULL) { - // Derive a replication task from the target Workspace for pushing. - $task = $this->getTask($target->getWorkspace(), 'push_replication_settings'); + // Derive a push replication task from the Workspace we are acting on. + $task = $this->getTask($source->getWorkspace(), 'push_replication_settings'); } // Push changes from $source to $target.