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

Breadcrumb

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

function CommentSelection::validateReferenceableEntities

Overrides DefaultSelection::validateReferenceableEntities

File

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

Class

CommentSelection
Provides specific access control for the comment entity type.

Namespace

Drupal\comment\Plugin\EntityReferenceSelection

Code

public function validateReferenceableEntities(array $ids) {
    $result = [];
    if ($ids) {
        $target_type = $this->configuration['target_type'];
        $entity_type = $this->entityTypeManager
            ->getDefinition($target_type);
        $query = $this->buildEntityQuery();
        // Mirror the conditions checked in buildEntityQuery().
        if (!$this->currentUser
            ->hasPermission('administer comments')) {
            $query->condition('status', 1);
        }
        $result = $query->condition($entity_type->getKey('id'), $ids, 'IN')
            ->execute();
    }
    return $result;
}

API Navigation

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