You are here

public function ChangesListController::viewChanges in Workspace 8

View a list of changes between current workspace and the target workspace.

Parameters

int $workspace:

Return value

array The render array to display for the page. The render array to display for the page.

Throws

\Doctrine\CouchDB\HTTP\HTTPException

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Core\Entity\EntityMalformedException

1 string reference to 'ChangesListController::viewChanges'
workspace.routing.yml in ./workspace.routing.yml
workspace.routing.yml

File

src/Controller/ChangesListController.php, line 106

Class

ChangesListController

Namespace

Drupal\workspace\Controller

Code

public function viewChanges($workspace) {
  $source_workspace = $this->workspaceManager
    ->load($workspace);
  if (!$source_workspace || !$source_workspace
    ->isPublished() || $source_workspace
    ->getQueuedForDelete()) {
    throw new NotFoundHttpException();
  }
  $source_workspace_pointer = $this
    ->getPointerToWorkspace($source_workspace);
  $target_workspace_pointer = $source_workspace
    ->get('upstream')->entity;
  if (!$target_workspace_pointer) {
    return [
      '#markup' => '<p>' . $this
        ->t('The upstream is not set.') . '</p>',
    ];
  }
  $target_workspace = $target_workspace_pointer
    ->getWorkspace();
  $replicator_exists = class_exists('Relaxed\\Replicator\\Replicator');
  $couchdbclient_exists = class_exists('Doctrine\\CouchDB\\CouchDBClient');
  $entities = [];
  if ($target_workspace instanceof WorkspaceInterface) {
    $entities = $this
      ->getChangesBetweenLocalWorkspaces($source_workspace, $target_workspace);
  }
  elseif ($replicator_exists && $couchdbclient_exists) {
    $entities = $this
      ->getChangesBetweenRemoteWorkspaces($source_workspace_pointer, $target_workspace_pointer);
  }
  return $this
    ->adminOverview($entities);
}