RevisionDiff.php in Replication 8
File
src/RevisionDiff/RevisionDiff.php
View source
<?php
namespace Drupal\replication\RevisionDiff;
use Drupal\multiversion\Entity\Index\RevisionIndexInterface;
use Drupal\multiversion\Entity\WorkspaceInterface;
class RevisionDiff implements RevisionDiffInterface {
protected $revIndex = [];
protected $revs;
public function __construct(RevisionIndexInterface $rev_index, WorkspaceInterface $workspace) {
$this->revIndex = $rev_index;
$this->workspaceId = $workspace
->id();
}
public function setRevisionIds(array $revs) {
$this->revs = $revs;
return $this;
}
public function getRevisionIds() {
return $this->revs;
}
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;
}
}