You are here

function hosting_get_features in Hosting 6.2

Same name and namespace in other branches
  1. 5 hosting.features.inc \hosting_get_features()
  2. 7.4 hosting.features.inc \hosting_get_features()
  3. 7.3 hosting.features.inc \hosting_get_features()

Get a listing of all known Hosting features.

Parameters

$refresh: (optional) Pass in TRUE to force the list of features to be rebuilt and not returned from the cache.

Return value

An array of Hosting features.

See also

hook_hosting_feature()

6 calls to hosting_get_features()
drush_hosting_post_pm_enable in ./hosting.drush.inc
Implements drush_hook_post_COMMAND().
hosting_feature in ./hosting.features.inc
Determine whether a specific feature of the hosting system is turned on.
hosting_features_form in ./hosting.features.inc
The Hosting features form.
hosting_features_form_submit in ./hosting.features.inc
Submit callback for the Hosting features form.
hosting_feature_node_types in ./hosting.features.inc
Determine which node types are provided by Hosting features.

... See full list

File

./hosting.features.inc, line 277
Include for functionality related to Hosting module features.

Code

function hosting_get_features($refresh = FALSE) {
  $cache = cache_get('hosting_features');
  if (empty($cache->data) || $refresh) {

    ## include any optional hosting.feature.*.inc files
    $files = drupal_system_listing("hosting\\.feature\\.[a-zA-Z_]*\\.inc\$", "modules");
    if (sizeof($files)) {
      foreach ($files as $name => $info) {
        include_once $info->filename;
      }
    }
    $functions = get_defined_functions();
    foreach ($functions['user'] as $function) {
      if (preg_match('/_hosting_feature$/', $function)) {
        $hooks[] = $function;
      }
    }
    $features = array();
    foreach ($hooks as $func) {
      $features = array_merge($features, $func());
    }

    // Add module dependencies, package and enabled status
    $module_cache = module_rebuild_cache();
    $modules = array();
    foreach ($features as $feature => $info) {
      $features[$feature]['enabled'] = $module_cache[$info['module']]->status;
      $features[$feature]['package'] = $module_cache[$info['module']]->info['package'];
      $features[$feature]['dependencies']['modules'] = $module_cache[$info['module']]->info['dependencies'];

      // Generate a list of features keyed by module name
      $modules[$info['module']] = $feature;
    }

    // Add Hosting feature dependencies, keyed by module
    foreach ($features as $feature => $info) {
      foreach ($info['dependencies']['modules'] as $dependency) {
        if (array_key_exists($dependency, $modules) && in_array($modules[$dependency], array_keys($features))) {
          $features[$feature]['dependencies']['features'][$dependency] = $modules[$dependency];
          $features[$modules[$dependency]]['dependencies']['reverse'][$info['module']] = $feature;
        }
      }
    }
    cache_set('hosting_features', $features);
    return $features;
  }
  else {
    return $cache->data;
  }
}