Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CommentSelection.php

function CommentSelection::buildEntityQuery

Overrides DefaultSelection::buildEntityQuery

2 calls to CommentSelection::buildEntityQuery()
CommentSelection::getReferenceableEntities in core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php
Gets the list of referenceable entities.
CommentSelection::validateReferenceableEntities in core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php
Validates which existing entities can be referenced.

File

core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php, line 27

Class

CommentSelection
Provides specific access control for the comment entity type.

Namespace

Drupal\comment\Plugin\EntityReferenceSelection

Code

protected 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 (!$this->currentUser
        ->hasPermission('administer comments')) {
        $query->condition('status', CommentInterface::PUBLISHED);
    }
    return $query;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal