You are here

protected function RNGSelectionBase::removeDuplicateRegistrants in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityReferenceSelection/RNGSelectionBase.php \Drupal\rng\Plugin\EntityReferenceSelection\RNGSelectionBase::removeDuplicateRegistrants()
  2. 8 src/Plugin/EntityReferenceSelection/RNGSelectionBase.php \Drupal\rng\Plugin\EntityReferenceSelection\RNGSelectionBase::removeDuplicateRegistrants()

Removes existing registered identities from the query.

Parameters

\Drupal\Core\Entity\Query\QueryInterface $query: The entity query to modify.

1 call to RNGSelectionBase::removeDuplicateRegistrants()
RNGSelectionBase::buildEntityQuery in src/Plugin/EntityReferenceSelection/RNGSelectionBase.php
Builds an EntityQuery to get referenceable entities.

File

src/Plugin/EntityReferenceSelection/RNGSelectionBase.php, line 98

Class

RNGSelectionBase
Base RNG selection plugin.

Namespace

Drupal\rng\Plugin\EntityReferenceSelection

Code

protected function removeDuplicateRegistrants(QueryInterface &$query) {
  if (!$this->eventMeta
    ->duplicateRegistrantsAllowed()) {
    $entity_ids = [];
    $registrants = $this->eventMeta
      ->getRegistrants($this->entityType
      ->id());
    foreach ($registrants as $registrant) {
      $entity_ids[] = $registrant
        ->getIdentityId()['entity_id'];
    }
    if ($entity_ids) {
      $query
        ->condition($this->entityType
        ->getKey('id'), $entity_ids, 'NOT IN');
    }
  }
}