function TermSelection::buildEntityQuery

Same name in other branches
  1. 9 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::buildEntityQuery()
  2. 8.9.x core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::buildEntityQuery()
  3. 10 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::buildEntityQuery()

Overrides DefaultSelection::buildEntityQuery

File

core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php, line 102

Class

TermSelection
Provides specific access control for the taxonomy_term entity type.

Namespace

Drupal\taxonomy\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = parent::buildEntityQuery($match, $match_operator);
    // Adding the 'taxonomy_term_access' tag is sadly insufficient for terms:
    // core requires us to also know about the concept of 'published' and
    // 'unpublished'.
    if (!$this->currentUser
        ->hasPermission('administer taxonomy')) {
        $query->condition('status', 1);
    }
    return $query;
}

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