You are here

protected function ViewsQueryAlter::getRevisionTableJoin in Workspace 8.2

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.

Return value

\Drupal\views\Plugin\views\join\JoinPluginInterface An adjusted views join object to add to the query.

1 call to ViewsQueryAlter::getRevisionTableJoin()
ViewsQueryAlter::ensureRevisionTable in src/ViewsQueryAlter.php
Adds the revision table of an entity type to a query object.

File

src/ViewsQueryAlter.php, line 369

Class

ViewsQueryAlter
Defines a class for altering views queries.

Namespace

Drupal\workspace

Code

protected function getRevisionTableJoin($relationship, $table, $field, $workspace_association_table) {
  $definition = [
    'table' => $table,
    'field' => $field,
    // Making this explicitly null allows the left table to be a formula.
    'left_table' => NULL,
    'left_field' => "COALESCE({$workspace_association_table}.target_entity_revision_id, {$relationship}.{$field})",
  ];

  /** @var \Drupal\views\Plugin\views\join\JoinPluginInterface $join */
  $join = $this->viewsJoinPluginManager
    ->createInstance('standard', $definition);
  $join->adjusted = TRUE;
  $join->workspace_adjusted = TRUE;
  return $join;
}