function entity_test_query_entity_test_access_alter

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_query_entity_test_access_alter()
  2. 8.9.x core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_query_entity_test_access_alter()
  3. 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_query_entity_test_access_alter()

Implements hook_query_entity_test_access_alter().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 812

Code

function entity_test_query_entity_test_access_alter(AlterableInterface $query) {
    if (!\Drupal::state()->get('entity_test_query_access')) {
        return;
    }
    
    /** @var \Drupal\Core\Database\Query\Select|\Drupal\Core\Database\Query\AlterableInterface $query */
    if (!\Drupal::currentUser()->hasPermission('view all entity_test_query_access entities')) {
        $query->condition('entity_test_query_access.name', 'published entity');
    }
}

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