You are here

function spaces_features_map in Spaces 6.2

Caches a map of feature component => feature name

9 calls to spaces_features_map()
spaces_features_menu_links_alter in ./spaces.module
Implementation of hook_features_menu_links_alter(). This function is deprecated and is no longer a real drupal_alter() callback. It is invoked directly from spaces_preprocess_page().
spaces_flush_caches in ./spaces.module
Implementation of hook_flush_caches().
spaces_handler_field_spaces_feature::render in includes/spaces_handler_field_spaces_feature.inc
spaces_init in ./spaces.module
Implementation of hook_init().
spaces_og_form_node_type_form_alter in spaces_og/spaces_og.module
Implementation of hook_form_alter for node_type_form.

... See full list

File

./spaces.module, line 1168

Code

function spaces_features_map($type = NULL, $reset = FALSE) {
  static $map;
  if (!isset($map) || $reset) {
    $map = array();
    $cache = cache_get('spaces_map', 'cache');
    if ($cache && !$reset) {
      $map = $cache->data;
    }
    else {

      // Generate component to feature map based on feature info files
      $features = spaces_features();
      foreach ($features as $feature_name => $feature) {
        foreach ($feature->info['features'] as $component => $items) {
          if (is_array($items)) {
            foreach ($items as $item) {
              if (!isset($map[$component][$item])) {
                $map[$component][$item] = $feature_name;
              }
            }
          }
        }
      }

      // Go through contexts and add relevant context components in as well
      $contexts = context_enabled_contexts();
      $components = array(
        'node',
        'views',
      );
      if (!empty($map['context'])) {
        foreach ($map['context'] as $identifier => $feature_name) {
          $context = $contexts[$identifier];
          if (!empty($context)) {
            foreach ($components as $component) {
              if (!empty($context->{$component})) {
                foreach ($context->{$component} as $item) {
                  if (!isset($map[$component][$item])) {
                    $map[$component][$item] = $feature_name;
                  }
                }
              }
            }
          }
        }
      }
      cache_set('spaces_map', $map, 'cache');
    }
  }
  if (!empty($type)) {
    return isset($map[$type]) ? $map[$type] : array();
  }
  return $map;
}