protected function UserFilteredSelection::buildEntityQuery in Workbench Access 8
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 UserSelection::buildEntityQuery
File
- src/
Plugin/ EntityReferenceSelection/ UserFilteredSelection.php, line 79
Class
- UserFilteredSelection
- Provides specific access control for the user entity type.
Namespace
Drupal\workbench_access\Plugin\EntityReferenceSelectionCode
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
if (isset($this->configuration['handler_settings'])) {
$handler_settings = $this->configuration['handler_settings'];
}
// Filter out the already referenced users.
if (isset($handler_settings['filter']['section_id'])) {
$id = $handler_settings['filter']['section_id'];
$editors = $this->userSectionStorage
->getEditors($this->scheme, $id);
if (count($editors)) {
$query
->condition('uid', array_keys($editors), 'NOT IN');
}
}
return $query;
}