This ticket is for writing out some documentation on how to use replication module from a developer perspective. Here is an outline of what I think is needed:

Executing a Replication

    /** Drupal\replication\Entity\ReplicationLog $replication_log */
    $replication_log = \Drupal::service('workspace.replicator_manager')->replicate(
      /** Drupal\workspace\WorkspacePointerInterface $source_workspace */
      $source_workspace,
      /** Drupal\workspace\WorkspacePointerInterface $target_workspace */
      $target_workspace,
      /** Drupal\replication\ReplicationTask\ReplicationTaskInterface $task */
      $task
    );

See also Drupal\deploy\Form\ReplicationActionForm and Drupal\workspace\EventSubscriber\WorkbenchModerationSubscriber.

Creating a Replicator

namespace Drupal\my_module;

/**
 * @Replicator(
 *   id = "myreplicator",
 *   label = "My Replicator"
 * )
 */
class MyReplicator implements ReplicatorInterface {
  /**
   * {@inheritdoc}
   */
  public function applies(WorkspacePointerInterface $source, WorkspacePointerInterface $target) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function replicate(WorkspacePointerInterface $source, WorkspacePointerInterface $target, ReplicationTaskInterface $task = NULL) {
    // Do really complicated logic, probably.
    // Create a ReplicationLog and return.
    return $replication_log;
  }
}

See also Drupal\workspace\InternalReplicator and Drupal\relaxed\CouchdbReplicator.

Adding Replication Filters

namespace Drupal\replication\Plugin\ReplicationFilter;

use Drupal\Core\Entity\EntityInterface;
use Drupal\replication\Plugin\ReplicationFilter\ReplicationFilterBase;
use Symfony\Component\HttpFoundation\ParameterBag;

/*
 * @ReplicationFilter(
 *   id = "my_filter",
 *   label = @Translation("My custom filter"),
 *   description = @Translation("What my custom filter does.")
 * )
 */
MyFilter extends ReplicationFilterBase {
  /**   
   * {@inheritdoc}
   */ 
  public function filter(EntityInterface $entity, ParameterBag $parameters) {
    return $entity->myprop == $parameters->get('myprop');
  }
}

See also Drupal\replication\Plugin\ReplicationFilter\EntityTypeFilter and Drupal\replication\Plugin\ReplicationFilter\PublishedFilter.

Comments

josephdpurcell created an issue.