1. 8.3.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.4.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
  1. <?php
  2. namespace Drupal\node\Plugin\views\filter;
  3. use Drupal\Core\Form\FormStateInterface;
  4. use Drupal\views\Plugin\views\filter\FilterPluginBase;
  5. /**
  6. * Filter by node_access records.
  7. *
  8. * @ingroup views_filter_handlers
  9. *
  10. * @ViewsFilter("node_access")
  11. */
  12. class Access extends FilterPluginBase {
  13. public function adminSummary() { }
  14. protected function operatorForm(&$form, FormStateInterface $form_state) { }
  15. public function canExpose() {
  16. return FALSE;
  17. }
  18. /**
  19. * See _node_access_where_sql() for a non-views query based implementation.
  20. */
  21. public function query() {
  22. $account = $this->view->getUser();
  23. if (!$account->hasPermission('administer nodes')) {
  24. $table = $this->ensureMyTable();
  25. $grants = db_or();
  26. foreach (node_access_grants('view', $account) as $realm => $gids) {
  27. foreach ($gids as $gid) {
  28. $grants->condition(db_and()
  29. ->condition($table . '.gid', $gid)
  30. ->condition($table . '.realm', $realm)
  31. );
  32. }
  33. }
  34. $this->query->addWhere('AND', $grants);
  35. $this->query->addWhere('AND', $table . '.grant_view', 1, '>=');
  36. }
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function getCacheContexts() {
  42. $contexts = parent::getCacheContexts();
  43. $contexts[] = 'user.node_grants:view';
  44. return $contexts;
  45. }
  46. }

Classes

Namesort descending Description
Access Filter by node_access records.