protected function FileEntityDealerManager::getDefinitionsByTypeAndScheme in Media Migration 8
Gets the plugin definitions for the specified file entity type.
Parameters
string $type: The file entity type.
string $scheme: The URI scheme.
Return value
mixed[] An array of the matching plugin definitions (empty array if no definitions were found).
1 call to FileEntityDealerManager::getDefinitionsByTypeAndScheme()
- FileEntityDealerManager::createInstanceFromTypeAndScheme in src/
FileEntityDealerManager.php - Gets the plugin definitions for the specified file entity type.
File
- src/
FileEntityDealerManager.php, line 61
Class
- FileEntityDealerManager
- Manages discovery and instantiation of file entity dealer plugins.
Namespace
Drupal\media_migrationCode
protected function getDefinitionsByTypeAndScheme(string $type, string $scheme) {
$definitions = $this
->getDefinitions();
$strict_list = array_filter($this
->getDefinitions(), function ($definition) use ($type, $scheme) {
return in_array($type, $definition['types'], TRUE) && in_array($scheme, $definition['schemes'], TRUE);
});
if (!empty($strict_list)) {
return $strict_list;
}
$only_type_list = array_filter($definitions, function ($definition) use ($type) {
return in_array($type, $definition['types'], TRUE) && empty($definition['schemes']);
});
if (!empty($only_type_list)) {
return $only_type_list;
}
$only_scheme_list = array_filter($definitions, function ($definition) use ($scheme) {
return empty($definition['types']) && in_array($scheme, $definition['schemes'], TRUE);
});
if (!empty($only_scheme_list)) {
return $only_scheme_list;
}
if (array_key_exists('fallback', $definitions)) {
return [
'fallback' => $definitions['fallback'],
];
}
return [];
}