public function ExtractFileValidator::isPrivateFileAllowed in Search API attachments 8
Same name and namespace in other branches
- 9.0.x src/ExtractFileValidator.php \Drupal\search_api_attachments\ExtractFileValidator::isPrivateFileAllowed()
Exclude private files from being indexed.
Only happens if the module is configured to do so(default behaviour).
Parameters
object $file: File object.
bool $excluded_private: Boolean value whether exclude private file.
Return value
bool TRUE if we should prevent current file from being indexed.
File
- src/
ExtractFileValidator.php, line 110
Class
- ExtractFileValidator
- Validator class for attachment indexing.
Namespace
Drupal\search_api_attachmentsCode
public function isPrivateFileAllowed($file, $excluded_private = TRUE) {
// Know if private files are allowed to be indexed.
$private_allowed = !$excluded_private;
// Know if current file is private.
$uri = $file
->getFileUri();
$file_is_private = FALSE;
if (substr($uri, 0, 10) == 'private://') {
$file_is_private = TRUE;
}
if (!$file_is_private) {
return TRUE;
}
else {
return $private_allowed;
}
}