class Access

Same name and namespace in other branches
  1. 11.x core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access
  2. 10 core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access
  3. 8.9.x core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access

Filter by node_access records.

Plugin annotation

@ViewsFilter("node_access");

Hierarchy

Expanded class hierarchy of Access

Related topics

44 string references to 'Access'
AccessManagerTest::setupAccessChecker in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Adds a default access check service to the container and the access manager.
AccessManagerTest::testCheckConjunctions in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests \Drupal\Core\Access\AccessManager::check() with conjunctions.
AccessManagerTest::testCheckException in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests that an access checker throws an exception for not allowed values.
AccessManagerTest::testCheckNamedRouteWithDefaultValue in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests the checkNamedRoute with default values.
AccessManagerTest::testCheckNamedRouteWithUpcastedValues in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests the checkNamedRoute with upcasted values.

... See full list

File

core/modules/node/src/Plugin/views/filter/Access.php, line 15

Namespace

Drupal\node\Plugin\views\filter
View source
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('bypass node access')) {
      $table = $this->ensureMyTable();
      $grants = $this->query
        ->getConnection()
        ->condition('OR');
      foreach (node_access_grants('view', $account) as $realm => $gids) {
        foreach ($gids as $gid) {
          $grants->condition($this->query
            ->getConnection()
            ->condition('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;
  }

}

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