You are here

class ReplicationTask in Replication 8

Same name and namespace in other branches
  1. 8.2 src/ReplicationTask/ReplicationTask.php \Drupal\replication\ReplicationTask\ReplicationTask

Hierarchy

Expanded class hierarchy of ReplicationTask

File

src/ReplicationTask/ReplicationTask.php, line 10

Namespace

Drupal\replication\ReplicationTask
View source
class ReplicationTask implements ReplicationTaskInterface {

  /**
   * The ID of the filter plugin to use during replication.
   *
   * @var string
   */
  protected $filter;

  /**
   * The parameters passed to the filter function.
   *
   * @var array
   */
  protected $parameters;

  /**
   * Number of items to return.
   *
   * @var int
   *   The limit of items.
   */
  protected $limit = 100;

  /**
   * Number of items to send pe BulkDocs request.
   *
   * @var int
   *   The limit of items.
   */
  private $bulkDocsLimit = 100;

  /**
   * @var string
   */
  protected $style = 'all_docs';

  /**
   * @var int
   */
  protected $heartbeat = 10000;

  /**
   * @var array
   */
  protected $docIds = NULL;

  /**
   * Start the results from the given update sequence.
   *
   * @var int
   *   The update sequence to start with.
   */
  private $sinceSeq = 0;

  /**
   * @var bool
   */
  protected $createTarget = FALSE;

  /**
   * @var bool
   */
  protected $continuous = FALSE;

  /**
   * {@inheritdoc}
   */
  public function setFilter($filter = NULL) {
    $this->filter = $filter;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getFilter() {
    return $this->filter;
  }

  /**
   * {@inheritdoc}
   */
  public function setParameters(array $parameters = NULL) {
    if ($parameters == NULL) {
      $parameters = [];
    }
    $this->parameters = $parameters;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setLimit($limit) {
    $this->limit = $limit;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setBulkDocsLimit($bulkDocsLimit) {
    $this->bulkDocsLimit = $bulkDocsLimit;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setParameter($name, $value) {
    if (!is_array($this->parameters)) {
      $this
        ->setParameters([]);
    }
    $this->parameters[$name] = $value;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setSinceSeq($sinceSeq) {
    $this->sinceSeq = $sinceSeq;
    return $this;
  }

  /**
   * @param mixed $style
   */
  public function setStyle($style) {
    $this->style = $style;
  }

  /**
   * {@inheritdoc}
   */
  public function getParameters() {
    return $this->parameters;
  }

  /**
   * {@inheritdoc}
   */
  public function getParametersAsArray() {
    return $this->parameters
      ->all();
  }

  /**
   * {@inheritdoc}
   */
  public function getParameter($name) {
    return $this->parameters
      ->get($name);
  }

  /**
   * {@inheritdoc}
   */
  public function getLimit() {
    return $this->limit;
  }

  /**
   * {@inheritdoc}
   */
  public function getBulkDocsLimit() {
    return $this->bulkDocsLimit;
  }

  /**
   * {@inheritdoc}
   */
  public function getSinceSeq() {
    return $this->sinceSeq;
  }

  /**
   * {@inheritdoc}
   */
  public function getStyle() {
    return $this->style;
  }

  /**
   * {@inheritdoc}
   */
  public function getDocIds() {
    return $this->docIds;
  }

  /**
   * {@inheritdoc}
   */
  public function setDocIds($docIds) {
    if ($docIds != NULL) {
      sort($docIds);
      if ($this->filter === NULL) {
        $this->filter = '_doc_ids';
      }
      elseif ($this->filter !== '_doc_ids') {
        throw new InvalidArgumentException('If docIds is specified, the filter should be set as _doc_ids');
      }
    }
    $this->docIds = $docIds;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getHeartbeat() {
    return $this->heartbeat;
  }

  /**
   * {@inheritdoc}
   */
  public function setHeartbeat($heartbeat) {
    $this->heartbeat = $heartbeat;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getCreateTarget() {
    return $this->createTarget;
  }

  /**
   * {@inheritdoc}
   */
  public function setCreateTarget($createTarget) {
    $this->createTarget = $createTarget;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getContinuous() {
    return $this->continuous;
  }

  /**
   * {@inheritdoc}
   */
  public function setContinuous($continuous) {
    $this->continuous = $continuous;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ReplicationTask::$bulkDocsLimit private property Number of items to send pe BulkDocs request.
ReplicationTask::$continuous protected property
ReplicationTask::$createTarget protected property
ReplicationTask::$docIds protected property
ReplicationTask::$filter protected property The ID of the filter plugin to use during replication.
ReplicationTask::$heartbeat protected property
ReplicationTask::$limit protected property Number of items to return.
ReplicationTask::$parameters protected property The parameters passed to the filter function.
ReplicationTask::$sinceSeq private property Start the results from the given update sequence.
ReplicationTask::$style protected property
ReplicationTask::getBulkDocsLimit public function Returns the BulkDocs limit. Overrides ReplicationTaskInterface::getBulkDocsLimit
ReplicationTask::getContinuous public function Overrides ReplicationTaskInterface::getContinuous
ReplicationTask::getCreateTarget public function Overrides ReplicationTaskInterface::getCreateTarget
ReplicationTask::getDocIds public function Overrides ReplicationTaskInterface::getDocIds
ReplicationTask::getFilter public function Get the ID of the filter plugin to use during replication. Overrides ReplicationTaskInterface::getFilter
ReplicationTask::getHeartbeat public function Overrides ReplicationTaskInterface::getHeartbeat
ReplicationTask::getLimit public function Returns the limit. Overrides ReplicationTaskInterface::getLimit
ReplicationTask::getParameter public function Get a parameter's value. Overrides ReplicationTaskInterface::getParameter
ReplicationTask::getParameters public function Get the parameters for the filter plugin. Overrides ReplicationTaskInterface::getParameters
ReplicationTask::getParametersAsArray public function Converts the parameter bag to an associative array and returns the array. Overrides ReplicationTaskInterface::getParametersAsArray
ReplicationTask::getSinceSeq public function Overrides ReplicationTaskInterface::getSinceSeq
ReplicationTask::getStyle public function Overrides ReplicationTaskInterface::getStyle
ReplicationTask::setBulkDocsLimit public function Set the limit of docs for BulkDocs per POST request. Overrides ReplicationTaskInterface::setBulkDocsLimit
ReplicationTask::setContinuous public function Overrides ReplicationTaskInterface::setContinuous
ReplicationTask::setCreateTarget public function Overrides ReplicationTaskInterface::setCreateTarget
ReplicationTask::setDocIds public function Overrides ReplicationTaskInterface::setDocIds
ReplicationTask::setFilter public function Set the ID of the filter plugin to use during replication. Overrides ReplicationTaskInterface::setFilter
ReplicationTask::setHeartbeat public function Overrides ReplicationTaskInterface::setHeartbeat
ReplicationTask::setLimit public function Set the limit of returned number of items. Overrides ReplicationTaskInterface::setLimit
ReplicationTask::setParameter public function Set a parameter for the filter plugin. Overrides ReplicationTaskInterface::setParameter
ReplicationTask::setParameters public function Set the parameters for the filter plugin. Overrides ReplicationTaskInterface::setParameters
ReplicationTask::setSinceSeq public function Set the update sequence to start with. Overrides ReplicationTaskInterface::setSinceSeq
ReplicationTask::setStyle public function Overrides ReplicationTaskInterface::setStyle