1. 8.5.x core/modules/node/src/Plugin/views/filter/Access.php
  2. 8.0.x core/modules/node/src/Plugin/views/filter/Access.php
  3. 8.1.x core/modules/node/src/Plugin/views/filter/Access.php
  4. 8.2.x core/modules/node/src/Plugin/views/filter/Access.php
  5. 8.3.x core/modules/node/src/Plugin/views/filter/Access.php
  6. 8.4.x core/modules/node/src/Plugin/views/filter/Access.php
  7. 8.6.x core/modules/node/src/Plugin/views/filter/Access.php

Namespace

Drupal\node\Plugin\views\filter

File

core/modules/node/src/Plugin/views/filter/Access.php
View source
<?php

namespace Drupal\node\Plugin\views\filter;

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

/**
 * Filter by node_access records.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("node_access")
 */
class Access extends FilterPluginBase {
  public function adminSummary() {
  }
  protected function operatorForm(&$form, FormStateInterface $form_state) {
  }
  public function canExpose() {
    return FALSE;
  }

  /**
   * See _node_access_where_sql() for a non-views query based implementation.
   */
  public function query() {
    $account = $this->view
      ->getUser();
    if (!$account
      ->hasPermission('administer nodes')) {
      $table = $this
        ->ensureMyTable();
      $grants = db_or();
      foreach (node_access_grants('view', $account) as $realm => $gids) {
        foreach ($gids as $gid) {
          $grants
            ->condition(db_and()
            ->condition($table . '.gid', $gid)
            ->condition($table . '.realm', $realm));
        }
      }
      $this->query
        ->addWhere('AND', $grants);
      $this->query
        ->addWhere('AND', $table . '.grant_view', 1, '>=');
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    $contexts = parent::getCacheContexts();
    $contexts[] = 'user.node_grants:view';
    return $contexts;
  }

}

Classes

Namesort descending Description
Access Filter by node_access records.