public function ExtractFileValidator::getExcludedMimes in Search API attachments 8
Same name and namespace in other branches
- 9.0.x src/ExtractFileValidator.php \Drupal\search_api_attachments\ExtractFileValidator::getExcludedMimes()
Get a corresponding array of excluded mime types.
Obtained from a space separated string of file extensions.
Parameters
string $extensions: If it's not null, the return will correspond to the extensions. If it is null,the return will correspond to the default excluded extensions.
string $excluded_extensions: Exclude extensions string.
Return value
array Array or mimes.
File
- src/
ExtractFileValidator.php, line 49
Class
- ExtractFileValidator
- Validator class for attachment indexing.
Namespace
Drupal\search_api_attachmentsCode
public function getExcludedMimes($extensions = NULL, $excluded_extensions = NULL) {
if (!$extensions && !empty($excluded_extensions)) {
$excluded_mimes_string = $excluded_extensions;
$excluded_mimes = explode(' ', $excluded_mimes_string);
}
else {
if (!$extensions) {
$extensions = explode(' ', self::DEFAULT_EXCLUDED_EXTENSIONS);
}
$excluded_mimes = [];
foreach ($extensions as $extension) {
$excluded_mimes[] = $this->mimeTypeGuesser
->guess('dummy.' . $extension);
}
}
// Ensure we get an array of unique mime values because many extension can
// map the the same mime type.
return array_unique($excluded_mimes);
}