You are here

public function WorkspaceAssociationStorage::getTrackedEntities in Workspace 8.2

Retrieves the content revisions tracked by a given workspace.

Parameters

string $workspace_id: The ID of the workspace.

bool $all_revisions: (optional) Whether to return all the tracked revisions for each entity or just the latest tracked revision. Defaults to FALSE.

Return value

array Returns a multidimensional array where the first level keys are entity type IDs and the values are an array of entity IDs keyed by revision IDs.

Overrides WorkspaceAssociationStorageInterface::getTrackedEntities

File

src/WorkspaceAssociationStorage.php, line 30

Class

WorkspaceAssociationStorage
Defines the storage handler class for the Workspace association entity type.

Namespace

Drupal\workspace

Code

public function getTrackedEntities($workspace_id, $all_revisions = FALSE) {
  $table = $all_revisions ? $this
    ->getRevisionTable() : $this
    ->getBaseTable();
  $query = $this->database
    ->select($table, 'base_table');
  $query
    ->fields('base_table', [
    'target_entity_type_id',
    'target_entity_id',
    'target_entity_revision_id',
  ])
    ->orderBy('target_entity_revision_id', 'ASC')
    ->condition('workspace', $workspace_id);
  $tracked_revisions = [];
  foreach ($query
    ->execute() as $record) {
    $tracked_revisions[$record->target_entity_type_id][$record->target_entity_revision_id] = $record->target_entity_id;
  }
  return $tracked_revisions;
}