Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / node / src / Plugin / views / filter / Status.php
1 <?php
2
3 namespace Drupal\node\Plugin\views\filter;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\filter\FilterPluginBase;
7
8 /**
9  * Filter by published status.
10  *
11  * @ingroup views_filter_handlers
12  *
13  * @ViewsFilter("node_status")
14  */
15 class Status extends FilterPluginBase {
16
17   public function adminSummary() {}
18
19   protected function operatorForm(&$form, FormStateInterface $form_state) {}
20
21   public function canExpose() {
22     return FALSE;
23   }
24
25   public function query() {
26     $table = $this->ensureMyTable();
27     $this->query->addWhereExpression($this->options['group'], "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1");
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function getCacheContexts() {
34     $contexts = parent::getCacheContexts();
35
36     $contexts[] = 'user';
37
38     return $contexts;
39   }
40
41 }