You are here

function hosting_get_features in Hosting 7.3

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

Get a listing of all known Hosting features.

Parameters

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

Return value

array An array of Hosting features.

See also

hook_hosting_feature()

9 calls to hosting_get_features()
hosting_determine_features_status in ./hosting.features.inc
Determine the status and actions to take on Hosting features.
hosting_feature in ./hosting.features.inc
Determine whether a specific feature of the hosting system is turned on.
hosting_features_disable in ./hosting.features.inc
Disable one or more Hosting features.
hosting_features_enable in ./hosting.features.inc
Enable one or more Hosting features.
hosting_features_form in ./hosting.features.inc
The Hosting features form.

... See full list

File

./hosting.features.inc, line 270
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-Z0-9_]*\\.inc\$/", "modules");
    if (count($files)) {
      foreach ($files as $name => $info) {
        include_once DRUPAL_ROOT . '/' . $info->uri;
      }
    }

    // We need the equivalent of module_invoke_all('hosting_feature'), but
    // including disabled features/modules too.
    $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 = system_rebuild_module_data();
    $modules = array();
    foreach ($features as $feature => $info) {
      if (isset($module_cache[$info['module']]->info['required']) && $module_cache[$info['module']]->info['required']) {
        $features[$feature]['status'] = HOSTING_FEATURE_REQUIRED;
      }
      $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) && array_key_exists($modules[$dependency], $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;
  }
}