protected function UserSelection::buildEntityQuery in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php \Drupal\user\Plugin\EntityReferenceSelection\UserSelection::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
- core/
modules/ user/ src/ Plugin/ EntityReferenceSelection/ UserSelection.php, line 149 - Contains \Drupal\user\Plugin\EntityReferenceSelection\UserSelection.
Class
- UserSelection
- Provides specific access control for the user entity type.
Namespace
Drupal\user\Plugin\EntityReferenceSelectionCode
protected 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);
}
// Filter by role.
$handler_settings = $this->configuration['handler_settings'];
if (!empty($handler_settings['filter']['role'])) {
$query
->condition('roles', $handler_settings['filter']['role'], 'IN');
}
// Adding the permission check is sadly insufficient for users: core
// requires us to also know about the concept of 'blocked' and 'active'.
if (!$this->currentUser
->hasPermission('administer users')) {
$query
->condition('status', 1);
}
return $query;
}