protected function FileDealerManager::getDefinitionsByFieldTypeAndScheme in Media Migration 8
Gets the plugin definitions for the specified scheme and main MIME type.
Parameters
string $scheme: The URI scheme.
string $mime: The main MIME type (the mime type's first part, before the slash).
Return value
mixed[] An array of the matching plugin definitions (empty array if no definitions were found).
1 call to FileDealerManager::getDefinitionsByFieldTypeAndScheme()
- FileDealerManager::createInstanceFromSchemeAndMime in src/
FileDealerManager.php - Returns a FileDealer plugin instance that matches the scheme and MIME.
File
- src/
FileDealerManager.php, line 61
Class
- FileDealerManager
- Manages discovery and instantiation of plain file dealer plugins.
Namespace
Drupal\media_migrationCode
protected function getDefinitionsByFieldTypeAndScheme(string $scheme, string $mime) {
$definitions = $this
->getDefinitions();
$strict_list = array_filter($definitions, function ($definition) use ($scheme, $mime) {
return in_array($scheme, $definition['schemes'], TRUE) && in_array($mime, $definition['mimes'], TRUE);
});
if (!empty($strict_list)) {
return $strict_list;
}
$only_mime_list = array_filter($definitions, function ($definition) use ($mime) {
return empty($definition['schemes']) && in_array($mime, $definition['mimes'], TRUE);
});
if (!empty($only_mime_list)) {
return $only_mime_list;
}
$only_scheme_list = array_filter($definitions, function ($definition) use ($scheme) {
return in_array($scheme, $definition['schemes'], TRUE) && empty($definition['mimes']);
});
if (!empty($only_scheme_list)) {
return $only_scheme_list;
}
if (array_key_exists('fallback', $definitions)) {
return [
'fallback' => $definitions['fallback'],
];
}
return [];
}