function ViewsQueryAlter::ensureWorkspaceAssociationTable
Same name in other branches
- 8.9.x core/modules/workspaces/src/ViewsQueryAlter.php \Drupal\workspaces\ViewsQueryAlter::ensureWorkspaceAssociationTable()
- 10 core/modules/workspaces/src/ViewsQueryAlter.php \Drupal\workspaces\ViewsQueryAlter::ensureWorkspaceAssociationTable()
- 11.x 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.
2 calls to ViewsQueryAlter::ensureWorkspaceAssociationTable()
- ViewsQueryAlter::alterQueryForEntityType in core/
modules/ workspaces/ src/ ViewsQueryAlter.php - Alters the entity type tables for a Views query.
- ViewsQueryAlter::ensureRevisionTable in core/
modules/ workspaces/ src/ ViewsQueryAlter.php - Adds the revision table of an entity type to a query object.
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.