protected function TermSelection::buildEntityQuery in Drupal 8
Same name and namespace in other branches
- 9 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::buildEntityQuery()
- 10 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::buildEntityQuery()
Builds an EntityQuery to get referenceable entities.
Parameters
string|null $match: (Optional) Text to match the label against. Defaults to NULL.
string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".
Return value
\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.
Overrides DefaultSelection::buildEntityQuery
File
- core/modules/ taxonomy/ src/ Plugin/ EntityReferenceSelection/ TermSelection.php, line 101 
Class
- TermSelection
- Provides specific access control for the taxonomy_term entity type.
Namespace
Drupal\taxonomy\Plugin\EntityReferenceSelectionCode
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;
}