protected function ViewsQueryAlter::ensureWorkspaceAssociationTable in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workspaces/src/ViewsQueryAlter.php \Drupal\workspaces\ViewsQueryAlter::ensureWorkspaceAssociationTable()
- 9 core/modules/workspaces/src/ViewsQueryAlter.php \Drupal\workspaces\ViewsQueryAlter::ensureWorkspaceAssociationTable()
Adds the 'workspace_association' table to a views query.
Parameters
string $entity_type_id: The ID of the entity type to join.
\Drupal\views\Plugin\views\query\Sql $query: The query plugin object for the query.
string $relationship: The primary table alias this table is related to.
Return value
string The alias of the 'workspace_association' table.
File
- core/
modules/ workspaces/ src/ ViewsQueryAlter.php, line 285
Class
- ViewsQueryAlter
- Defines a class for altering views queries.
Namespace
Drupal\workspacesCode
protected function ensureWorkspaceAssociationTable($entity_type_id, Sql $query, $relationship) {
if (isset($query->tables[$relationship]['workspace_association'])) {
return $query->tables[$relationship]['workspace_association']['alias'];
}
$table_data = $this->viewsData
->get($query->relationships[$relationship]['base']);
// Construct the join.
$definition = [
'table' => 'workspace_association',
'field' => 'target_entity_id',
'left_table' => $relationship,
'left_field' => $table_data['table']['base']['field'],
'extra' => [
[
'field' => 'target_entity_type_id',
'value' => $entity_type_id,
],
[
'field' => 'workspace',
'value' => $this->workspaceManager
->getActiveWorkspace()
->id(),
],
],
'type' => 'LEFT',
];
$join = $this->viewsJoinPluginManager
->createInstance('standard', $definition);
$join->adjusted = TRUE;
return $query
->queueTable('workspace_association', $relationship, $join);
}