function ViewsOperations::getRevisionTableJoin
Fetches a join for a revision table using the workspace_association table.
Parameters
string $relationship: The relationship to use in the view.
string $table: The table name.
string $field: The field to join on.
string $workspace_association_table: The alias of the 'workspace_association' table joined to the main entity table.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type that is being queried.
Return value
\Drupal\views\Plugin\views\join\JoinPluginInterface An adjusted views join object to add to the query.
Throws
\Drupal\Component\Plugin\Exception\PluginException
1 call to ViewsOperations::getRevisionTableJoin()
- ViewsOperations::ensureRevisionTable in core/
modules/ workspaces/ src/ Hook/ ViewsOperations.php - Adds the revision table of an entity type to a query object.
File
-
core/
modules/ workspaces/ src/ Hook/ ViewsOperations.php, line 326
Class
- ViewsOperations
- Defines a class for altering views queries.
Namespace
Drupal\workspaces\HookCode
protected function getRevisionTableJoin(string $relationship, string $table, string $field, string $workspace_association_table, EntityTypeInterface $entity_type) : JoinPluginInterface {
$definition = [
'table' => $table,
'field' => $field,
'left_table' => $relationship,
'left_formula' => "COALESCE({$workspace_association_table}.target_entity_revision_id, {$relationship}.{$field})",
];
if ($entity_type->isTranslatable() && $this->languageManager
->isMultilingual()) {
$langcode_field = $entity_type->getKey('langcode');
$definition['extra'] = [
[
'field' => $langcode_field,
'left_field' => $langcode_field,
],
];
}
/** @var \Drupal\views\Plugin\views\join\JoinPluginInterface $join */
$join = $this->viewsJoinPluginManager
->createInstance('standard', $definition);
$join->adjusted = TRUE;
$this->adjustedTables[$join] = TRUE;
return $join;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.