You are here

function media_get_registered_modules in D7 Media 6

Gets all of the modules which register with Media.

Parameters

array $ids: (Optional) If this contains an array of id strings, then return only the specified ids.

boolean $reset: (Optional) If TRUE, then reset the static cache.

Return value

array An array of registrations, keyed by implementing function name, in the form of: 'module' => The module implementing the hook. 'uri' => The scheme the stream wrapper handles, default is 'public://'. 'types' => The mime types this module handles, defaults to * (all). 'name' => A human readable name, displayed on forms. 'kind' => Kind of functionality: 'resource' or 'format'. 'description' => A verbose description of functionality. 'callbacks' => An array of key => functions called for data. 'fields' => What fields does this functionality operate on? 'validation' => @todo 'display' => @todo

6 calls to media_get_registered_modules()
media_get_fields in ./media.module
Get all fields that can be enabled on a field type.
media_get_registration_kinds in ./media.module
Parsing function for the registrations to hand back the kinds of modules registering. Used to select all formatters, resources, etc.
media_get_resources in ./media.module
Fetch all resources registered and call the specified callback. I
media_registration_data in ./media.module
Parsing function for the registrations to hand back the kinds of modules registering.
media_registration_item_formatters in ./media.module
Return a set of formatters which can format the specified item.

... See full list

File

./media.module, line 154
Media API

Code

function media_get_registered_modules($ids = NULL, $reset = FALSE) {
  static $registrations;

  // Only build cache the first time the function is called, or if we reset it.
  if (is_NULL($registrations) || $reset) {
    $registrations = array();

    // Get all the modules which implement hook_media_register().
    foreach (module_implements('media_register') as $module) {
      $function = $module . '_media_register';

      // Get all the registrations defined by the module.
      $registration = $function();

      // TODO: Fix this. Why are we calling $function twice (jmstacey 6/2/09)?
      // Iterate through each registration defined by the implementing module.
      foreach (array_keys($function()) as $key) {

        // Add the module name to each registration.
        // Default the 'module' key of the registration to the implementing module.
        $registration[$key]['module'] = $registration[$key]['module'] ? $registration[$key]['module'] : $module;

        // translate strings now
        $registration[$key]['name'] = t($registration[$key]['name']);
        $registration[$key]['description'] = t($registration[$key]['description']);

        // Default the 'uri' to public://.
        if (!$registraton[$key]['uri']) {
          $registration[$key]['uri'] = MEDIA_RESOURCE_URI_DEFAULT;
        }

        // Default 'types' to * (all).
        if (!$registration[$key]['types']) {
          $registration[$key]['types'] = MEDIA_TYPES_DEFAULT;
        }
      }

      // Add the new registrations to our total.
      $registrations = array_merge($registrations, $registration);
    }
  }

  // Return requested registrations.
  if ($ids) {
    foreach ($ids as $id) {
      $return[$id] = $registrations[$id];
    }
    return $return;
  }
  return $registrations;
}