GroupSiblings.php in RNG - Events and Registrations 8.2
File
src/Plugin/EntityReferenceSelection/GroupSiblings.php
View source
<?php
namespace Drupal\rng\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\rng\Entity\GroupInterface;
class GroupSiblings extends SelectionBase {
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
if (($registration_group = $this->configuration['entity']) instanceof GroupInterface) {
if (($event = $registration_group
->getEvent()) instanceof EntityInterface) {
$group = $query
->andConditionGroup()
->condition('event__target_type', $event
->getEntityTypeId(), '=')
->condition('event__target_id', $event
->id(), '=');
$query
->condition($group);
}
$id_key = $registration_group
->getEntityType()
->getKey('id');
$query
->condition($id_key, [
$registration_group
->id(),
], 'NOT IN');
}
$query
->condition('source', NULL, 'IS NULL');
return $query;
}
}