X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fworkspaces%2Fsrc%2FWorkspaceAssociationStorage.php;fp=web%2Fcore%2Fmodules%2Fworkspaces%2Fsrc%2FWorkspaceAssociationStorage.php;h=6355e79220e49aa51251fcf1a9bb033e473ce393;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/workspaces/src/WorkspaceAssociationStorage.php b/web/core/modules/workspaces/src/WorkspaceAssociationStorage.php new file mode 100644 index 000000000..6355e7922 --- /dev/null +++ b/web/core/modules/workspaces/src/WorkspaceAssociationStorage.php @@ -0,0 +1,59 @@ +database + ->delete($this->entityType->getBaseTable()) + ->condition('workspace', $workspace->id()) + ->execute(); + $this->database + ->delete($this->entityType->getRevisionTable()) + ->condition('workspace', $workspace->id()) + ->execute(); + } + + /** + * {@inheritdoc} + */ + 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; + } + + /** + * {@inheritdoc} + */ + public function getEntityTrackingWorkspaceIds(EntityInterface $entity) { + $query = $this->database->select($this->getBaseTable(), 'base_table'); + $query + ->fields('base_table', ['workspace']) + ->condition('target_entity_type_id', $entity->getEntityTypeId()) + ->condition('target_entity_id', $entity->id()); + + return $query->execute()->fetchCol(); + } + +}