You are here

protected function RegistrationGroupSelection::buildEntityQuery in RNG - Events and Registrations 3.x

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

Builds an EntityQuery to get referenceable entities.

Parameters

string|null $match: (Optional) Text to match the label against. Defaults to NULL.

string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".

Return value

\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.

Overrides DefaultSelection::buildEntityQuery

File

src/Plugin/EntityReferenceSelection/RegistrationGroupSelection.php, line 25

Class

RegistrationGroupSelection
Provides specific access control for registration groups.

Namespace

Drupal\rng\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  if (($event = $this->configuration['entity']) instanceof EntityInterface) {
    $group = $query
      ->andConditionGroup()
      ->condition('event__target_type', $event
      ->getEntityTypeId(), '=')
      ->condition('event__target_id', $event
      ->id(), '=');
    $query
      ->condition($group);
    $query
      ->condition('source', NULL, 'IS NULL');
  }
  return $query;
}