public function UserSelection::buildEntityQuery

Overrides SelectionBase::buildEntityQuery().

Overrides SelectionBase::buildEntityQuery

File

drupal/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php, line 83
Contains \Drupal\user\Plugin\entity_reference\selection\UserSelection.

Class

UserSelection
Provides specific access control for the user entity type.

Namespace

Drupal\user\Plugin\entity_reference\selection

Code

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

  // The user entity doesn't have a label column.
  if (isset($match)) {
    $query
      ->condition('name', $match, $match_operator);
  }

  // Adding the 'user_access' tag is sadly insufficient for users: core
  // requires us to also know about the concept of 'blocked' and 'active'.
  if (!user_access('administer users')) {
    $query
      ->condition('status', 1);
  }
  return $query;
}