You are here

public function Status::query in Drupal 8

Same name in this branch
  1. 8 core/modules/node/src/Plugin/views/filter/Status.php \Drupal\node\Plugin\views\filter\Status::query()
  2. 8 core/modules/media/src/Plugin/views/filter/Status.php \Drupal\media\Plugin\views\filter\Status::query()
Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/views/filter/Status.php \Drupal\node\Plugin\views\filter\Status::query()

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

core/modules/node/src/Plugin/views/filter/Status.php, line 25

Class

Status
Filter by published status.

Namespace

Drupal\node\Plugin\views\filter

Code

public function query() {
  $table = $this
    ->ensureMyTable();
  $snippet = "{$table}.status = 1 OR ({$table}.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1";
  if ($this->moduleHandler
    ->moduleExists('content_moderation')) {
    $snippet .= ' OR ***VIEW_ANY_UNPUBLISHED_NODES*** = 1';
  }
  $this->query
    ->addWhereExpression($this->options['group'], $snippet);
}