You are here

public function CurrentWorkspace::query in Multiversion 8

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides FilterPluginBase::query

File

src/Plugin/views/filter/CurrentWorkspace.php, line 23

Class

CurrentWorkspace
Filter by current workspace.

Namespace

Drupal\multiversion\Plugin\views\filter

Code

public function query() {
  $table = $this
    ->ensureMyTable();
  $active_workspace = \Drupal::service('workspace.manager')
    ->getActiveWorkspaceId();
  $placeholder = $this
    ->placeholder();
  $this->query
    ->addWhereExpression($this->options['group'], "{$table}.workspace = {$placeholder}", [
    $placeholder => $active_workspace,
  ]);
}