You are here

public function SelectionEntityTypeUser::buildEntityFieldQuery in Entity reference 8

Build an EntityFieldQuery to get referencable entities.

Overrides SelectionBase::buildEntityFieldQuery

File

lib/Drupal/entityreference/Plugin/Type/Selection/SelectionEntityTypeUser.php, line 21
Definition of Drupal\entityreference\Plugin\entityreference\selection\SelectionEntityTypeNode.

Class

SelectionEntityTypeUser

Namespace

Drupal\entityreference\Plugin\Type\Selection

Code

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

  // The user entity doesn't have a label column.
  if (isset($match)) {
    $query
      ->propertyCondition('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
      ->propertyCondition('status', 1);
  }
  return $query;
}