function Tables::addWorkspaceAssociationJoin
Adds a new join to the 'workspace_association' table for an entity base table.
This method assumes that the active workspace has already been determined to be a non-default workspace.
Parameters
string $entity_type_id: The ID of the entity type whose base table we are joining.
string $base_table_alias: The alias of the entity type's base table.
string $active_workspace_id: The ID of the active workspace.
Return value
string The alias of the joined table.
1 call to Tables::addWorkspaceAssociationJoin()
- Tables::addNextBaseTable in core/
modules/ workspaces/ src/ EntityQuery/ Tables.php  - Add the next entity base table.
 
File
- 
              core/
modules/ workspaces/ src/ EntityQuery/ Tables.php, line 143  
Class
- Tables
 - Alters entity queries to use a workspace revision instead of the default one.
 
Namespace
Drupal\workspaces\EntityQueryCode
public function addWorkspaceAssociationJoin($entity_type_id, $base_table_alias, $active_workspace_id) {
  if (!isset($this->contentWorkspaceTables[$base_table_alias])) {
    $entity_type = $this->entityTypeManager
      ->getActiveDefinition($entity_type_id);
    $id_field = $entity_type->getKey('id');
    // LEFT join the Workspace association entity's table so we can properly
    // include live content along with a possible workspace-specific revision.
    $this->contentWorkspaceTables[$base_table_alias] = $this->sqlQuery
      ->leftJoin('workspace_association', NULL, "[%alias].[target_entity_type_id] = '{$entity_type_id}' AND [%alias].[target_entity_id] = [{$base_table_alias}].[{$id_field}] AND [%alias].[workspace] = '{$active_workspace_id}'");
    $this->baseTablesEntityType[$base_table_alias] = $entity_type->id();
  }
  return $this->contentWorkspaceTables[$base_table_alias];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.