public function CommentSelection::buildEntityQuery

Overrides SelectionBase::buildEntityQuery().

Overrides SelectionBase::buildEntityQuery

File

drupal/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php, line 32
Contains \Drupal\comment\Plugin\entity_reference\selection\CommentSelection.

Class

CommentSelection
Provides specific access control for the comment entity type.

Namespace

Drupal\comment\Plugin\entity_reference\selection

Code

public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);

  // Adding the 'comment_access' tag is sadly insufficient for comments:
  // core requires us to also know about the concept of 'published' and
  // 'unpublished'.
  if (!user_access('administer comments')) {
    $query
      ->condition('status', COMMENT_PUBLISHED);
  }
  return $query;
}