You are here

protected function RngContactRngSelection::buildEntityQuery in RNG Contact 8

File

src/Plugin/EntityReferenceSelection/RngContactRngSelection.php, line 24

Class

RngContactRngSelection
Provides selection for contact entities when registering.

Namespace

Drupal\rng_contact\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);

  // Select contacts owned by the user.
  if ($this->currentUser
    ->isAuthenticated()) {
    $query
      ->condition('owner', $this->currentUser
      ->id(), '=');
  }
  else {

    // Cancel the query.
    $query
      ->condition($this->entityType
      ->getKey('id'), NULL, 'IS NULL');
    return $query;
  }
  return $query;
}