protected function UserMatcher::buildEntityQuery in Linkit 8.5
Same name and namespace in other branches
- 8.4 src/Plugin/Linkit/Matcher/UserMatcher.php \Drupal\linkit\Plugin\Linkit\Matcher\UserMatcher::buildEntityQuery()
Builds an EntityQuery to get entities.
Parameters
string $search_string: Text to match the label against.
Return value
\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.
Overrides EntityMatcher::buildEntityQuery
File
- src/
Plugin/ Linkit/ Matcher/ UserMatcher.php, line 108
Class
- UserMatcher
- Provides specific linkit matchers for the user entity type.
Namespace
Drupal\linkit\Plugin\Linkit\MatcherCode
protected function buildEntityQuery($search_string) {
$query = parent::buildEntityQuery($search_string);
$search_string = $this->database
->escapeLike($search_string);
// The user entity don't specify a label key so we have to do it instead.
$query
->condition('name', '%' . $search_string . '%', 'LIKE');
// Filter by role.
if (!empty($this->configuration['roles'])) {
$query
->condition('roles', $this->configuration['roles'], 'IN');
}
if ($this->configuration['include_blocked'] !== TRUE || !$this->currentUser
->hasPermission('administer users')) {
$query
->condition('status', 1);
}
return $query;
}