public function ContentAccess::preprocessSearchQuery in Search API 8
Preprocesses a search query.
Parameters
\Drupal\search_api\Query\QueryInterface $query: The object representing the query to be executed.
Overrides ProcessorPluginBase::preprocessSearchQuery
File
- src/
Plugin/ search_api/ processor/ ContentAccess.php, line 236
Class
- ContentAccess
- Adds content access checks for nodes and comments.
Namespace
Drupal\search_api\Plugin\search_api\processorCode
public function preprocessSearchQuery(QueryInterface $query) {
if (!$query
->getOption('search_api_bypass_access')) {
$account = $query
->getOption('search_api_access_account', $this
->getCurrentUser());
if (is_numeric($account)) {
$account = User::load($account);
}
if ($account instanceof AccountInterface) {
$this
->addNodeAccess($query, $account);
}
else {
$account = $query
->getOption('search_api_access_account', $this
->getCurrentUser());
if ($account instanceof AccountInterface) {
$account = $account
->id();
}
if (!is_scalar($account)) {
$account = var_export($account, TRUE);
}
$this
->getLogger()
->warning('An illegal user UID was given for node access: @uid.', [
'@uid' => $account,
]);
}
}
}