You are here

public function TeamMembersSelection::getReferenceableEntities in Apigee Edge 8

Gets the list of referenceable entities.

Return value

array A nested array of entities, the first level is keyed by the entity bundle, which contains an array of entity labels (escaped), keyed by the entity ID.

Overrides DefaultSelection::getReferenceableEntities

File

modules/apigee_edge_teams/src/Plugin/EntityReferenceSelection/TeamMembersSelection.php, line 235

Class

TeamMembersSelection
Provides a team member entity selection plugin.

Namespace

Drupal\apigee_edge_teams\Plugin\EntityReferenceSelection

Code

public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
  $target_type = $this
    ->getConfiguration()['target_type'];
  $query = $this
    ->buildEntityQuery($match, $match_operator);
  if ($limit > 0) {
    $query
      ->range(0, $limit);
  }
  $result = $query
    ->execute();
  if (empty($result)) {
    return [];
  }
  $options = [];
  $entities = $this->entityTypeManager
    ->getStorage($target_type)
    ->loadMultiple($result);

  /* @var \Drupal\user\UserInterface $entity */
  foreach ($entities as $id => $entity) {
    $options[$target_type][$id] = $entity
      ->getEmail();
  }
  return $options;
}