You are here

function features_get_default_map in Features 6

Same name and namespace in other branches
  1. 7.2 features.export.inc \features_get_default_map()
  2. 7 features.export.inc \features_get_default_map()

Get a map of components to their providing modules.

12 calls to features_get_default_map()
content_features_export in includes/features.content.inc
Implementation of hook_features_export().
context_features_export in includes/features.context.inc
Implementation of hook_features_export().
features_export_form in ./features.admin.inc
Form callback for features export form. Acts as a router based on the form_state.
fieldgroup_features_export in includes/features.fieldgroup.inc
Implementation of hook_features_export().
imagecache_features_export in includes/features.imagecache.inc
Implementation of hook_features_export().

... See full list

File

./features.export.inc, line 687

Code

function features_get_default_map($component, $attribute = NULL, $callback = NULL, $reset = FALSE) {
  static $map = array();
  features_include();
  features_include_defaults($component);
  if ((!isset($map[$component]) || $reset) && ($default_hook = features_get_default_hooks($component))) {
    $map[$component] = array();
    foreach (module_implements($default_hook) as $module) {
      if ($defaults = features_get_default($component, $module)) {
        foreach ($defaults as $key => $object) {
          if (isset($callback)) {
            if ($object_key = $callback($object)) {
              $map[$component][$object_key] = $module;
            }
          }
          elseif (isset($attribute)) {
            if (is_object($object) && isset($object->{$attribute})) {
              $map[$component][$object->{$attribute}] = $module;
            }
            elseif (is_array($object) && isset($object[$attribute])) {
              $map[$component][$object[$attribute]] = $module;
            }
          }
          elseif (!isset($attribute) && !isset($callback)) {
            if (!is_numeric($key)) {
              $map[$component][$key] = $module;
            }
          }
          else {
            return FALSE;
          }
        }
      }
    }
  }
  return isset($map[$component]) ? $map[$component] : FALSE;
}