function EntityTestHooks::queryEntityTestAccessAlter

Implements hook_query_entity_test_access_alter().

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 679

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function queryEntityTestAccessAlter(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.