Status.php

Same filename in this branch
  1. 8.9.x core/modules/file/src/Plugin/views/filter/Status.php
  2. 8.9.x core/modules/node/src/Plugin/views/filter/Status.php
Same filename in other branches
  1. 9 core/modules/media/src/Plugin/views/filter/Status.php
  2. 9 core/modules/file/src/Plugin/views/filter/Status.php
  3. 9 core/modules/node/src/Plugin/views/filter/Status.php
  4. 10 core/modules/media/src/Plugin/views/filter/Status.php
  5. 10 core/modules/file/src/Plugin/views/filter/Status.php
  6. 10 core/modules/node/src/Plugin/views/filter/Status.php
  7. 11.x core/modules/media/src/Plugin/views/filter/Status.php
  8. 11.x core/modules/file/src/Plugin/views/filter/Status.php
  9. 11.x core/modules/node/src/Plugin/views/filter/Status.php

Namespace

Drupal\media\Plugin\views\filter

File

core/modules/media/src/Plugin/views/filter/Status.php

View source
<?php

namespace Drupal\media\Plugin\views\filter;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\filter\FilterPluginBase;

/**
 * Filter by published status.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("media_status")
 */
class Status extends FilterPluginBase {
    
    /**
     * {@inheritdoc}
     */
    public function adminSummary() {
    }
    
    /**
     * {@inheritdoc}
     */
    protected function operatorForm(&$form, FormStateInterface $form_state) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function canExpose() {
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function query() {
        $table = $this->ensureMyTable();
        $snippet = "{$table}.status = 1 OR ({$table}.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_MEDIA*** = 1) OR ***ADMINISTER_MEDIA*** = 1";
        if ($this->moduleHandler
            ->moduleExists('content_moderation')) {
            $snippet .= ' OR ***VIEW_ANY_UNPUBLISHED_NODES*** = 1';
        }
        $this->query
            ->addWhereExpression($this->options['group'], $snippet);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheContexts() {
        $contexts = parent::getCacheContexts();
        $contexts[] = 'user';
        return $contexts;
    }

}

Classes

Title Deprecated Summary
Status Filter by published status.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.