function emapi_get_provider_classes in Embedded Media Field 6.3
Builds a registry of Media provider classes.
Each module supporting a Media provider will need to implement hook_emapi_register, which will need to return an associated array keyed by the scheme, with an array containing at least the following key => value pairs. Note that the scheme portion of the URI this class supports is in the form of scheme://identifier/id. 'class_name' => The actual name of the class. The following key => value pairs are optional, and will otherwise be automatically derived: 'name' => The human-readable name of the scheme. 'description' => A description of the scheme. 'path' => The path where the class file resides. 'file' => The file containing the class definition. 'module' => The module defining the class. 'url' => The URL to the remote media provider, if applicable. The following key => value pair will be automatically set to the association and cannot be overridden: 'scheme' => The scheme portion of the URI.
Parameters
string $scheme: (Optional) The scheme of the specific class registration to return.
boolean $reset: (Optional) If TRUE, then reset the registration.
Return value
array If $scheme is specified, then return only the specified class array, or NULL if there is no such registered class. Otherwise, return the entiry registry.
8 calls to emapi_get_provider_classes()
- emapi_get_provider_class in emapi/
emapi.module - Returns the registered class for a specific provider.
- emapi_get_provider_class_by_class_name in emapi/
emapi.module - Return the registered EmAPI class specified by name.
- emapi_init in emapi/
emapi.module - Implementation of hook_init().
- emapi_media_delete in emapi/
emapi.module - Delete a media object from the database.
- emapi_parse in emapi/
emapi.module - Parses a URL or embed code into a media object.
File
- emapi/
emapi.module, line 87 - Provides an API for parsing, storage, and display of third party media.
Code
function emapi_get_provider_classes($scheme = NULL, $reset = FALSE) {
static $emapi_registered_classes;
if ($reset || !isset($emapi_registered_classes)) {
$emapi_registered_classes = array();
// Build our media object class registry.
foreach (module_implements('emapi_register') as $module) {
foreach (module_invoke($module, 'emapi_register') as $scheme_name => $class) {
$emapi_registered_classes[$scheme_name] = is_array($class) ? $class : array();
$emapi_registered_classes[$scheme_name]['scheme'] = $scheme_name;
if (!isset($emapi_registered_classes[$scheme_name]['name'])) {
$emapi_registered_classes[$scheme_name]['name'] = t($scheme_name);
}
if (!isset($emapi_registered_classes[$scheme_name]['description'])) {
$emapi_registered_classes[$scheme_name]['description'] = t('Class definition for @scheme.', array(
'@scheme' => $scheme_name,
));
}
if (!isset($emapi_registered_classes[$scheme_name]['path'])) {
$emapi_registered_classes[$scheme_name]['path'] = drupal_get_path('module', $module);
}
if (!isset($emapi_registered_classes[$scheme_name]['file'])) {
$emapi_registered_classes[$scheme_name]['file'] = $class_name . '.inc';
}
if (!isset($emapi_registered_classes[$scheme_name]['module'])) {
$emapi_registered_classes[$scheme_name]['module'] = $module;
}
}
}
}
if (isset($scheme) && isset($emapi_registered_classes[$scheme])) {
return $emapi_registered_classes[$scheme];
}
else {
if (!isset($scheme)) {
return $emapi_registered_classes;
}
}
}