You are here

protected function ChangesListController::getChangesBetweenLocalWorkspaces in Workspace 8

Return the array with changed entities for workspaces on the same site.

Parameters

$source_workspace:

$target_workspace:

Return value

array

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to ChangesListController::getChangesBetweenLocalWorkspaces()
ChangesListController::viewChanges in src/Controller/ChangesListController.php
View a list of changes between current workspace and the target workspace.

File

src/Controller/ChangesListController.php, line 139

Class

ChangesListController

Namespace

Drupal\workspace\Controller

Code

protected function getChangesBetweenLocalWorkspaces($source_workspace, $target_workspace) {
  $since = $this->state
    ->get('last_sequence.workspace.' . $source_workspace
    ->id(), 0);

  // Get changes on the source workspace.
  $source_changes = $this->changesFactory
    ->get($source_workspace)
    ->setSince($since)
    ->getNormal();
  $data = [];
  foreach (array_reverse($source_changes) as $source_change) {
    $data[$source_change['id']] = [];
    foreach ($source_change['changes'] as $change) {
      $data[$source_change['id']][] = $change['rev'];
    }
  }

  // Get revisions the target workspace is missing.
  $revs_diff = $this->revisionDiffFactory
    ->get($target_workspace)
    ->setRevisionIds($data)
    ->getMissing();
  return $this
    ->getEntitiesFromRevsDiff($source_workspace, $revs_diff);
}