You are here

class RevisionDiff in Replication 8.2

Same name and namespace in other branches
  1. 8 src/RevisionDiff/RevisionDiff.php \Drupal\replication\RevisionDiff\RevisionDiff

Hierarchy

Expanded class hierarchy of RevisionDiff

1 file declares its use of RevisionDiff
RevisionDiffFactory.php in src/RevisionDiffFactory.php

File

src/RevisionDiff/RevisionDiff.php, line 8

Namespace

Drupal\replication\RevisionDiff
View source
class RevisionDiff implements RevisionDiffInterface {

  /**
   * @var \Drupal\multiversion\Entity\Index\RevisionIndexInterface
   */
  protected $revIndex = [];

  /**
   * @var string[]
   */
  protected $revs;

  /**
   * @param \Drupal\multiversion\Entity\Index\RevisionIndexInterface $rev_index
   * @param \Drupal\multiversion\Entity\WorkspaceInterface $workspace
   */
  public function __construct(RevisionIndexInterface $rev_index, WorkspaceInterface $workspace) {
    $this->revIndex = $rev_index;
    $this->workspaceId = $workspace
      ->id();
  }

  /**
   * {@inheritdoc}
   */
  public function setRevisionIds(array $revs) {
    $this->revs = $revs;
    return $this;
  }

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

  /**
   * {@inheritdoc}
   *
   * @todo {@link https://www.drupal.org/node/2344005 Implement the
   *   possible_ancestors key.}
   */
  public function getMissing() {
    $missing = [];
    foreach ($this
      ->getRevisionIds() as $uuid => $revs) {
      $keys = [];
      foreach ($revs as $rev) {
        $keys[] = "{$uuid}:{$rev}";
      }
      $existing = $this->revIndex
        ->useWorkspace($this->workspaceId)
        ->getMultiple($keys);
      foreach ($revs as $rev) {
        if (!isset($existing["{$uuid}:{$rev}"])) {
          $missing[$uuid]['missing'][] = $rev;
        }
      }
    }
    return $missing;
  }

}

Members