You are here

function features_get_components in Features 7

Same name and namespace in other branches
  1. 6 features.module \features_get_components()
  2. 7.2 features.module \features_get_components()

Returns the array of supported components.

Parameters

$component: A specific type of component that supports features.

$key: A key that hook_features_api supports.

Return value

An array of component labels keyed by the component names.

See also

hook_features_api

17 calls to features_get_components()
FeaturesEnableTestCase::testFeaturesGetComponents in tests/features.test
Run test for features_get_components on enable.
features_export_build_form_populate in ./features.admin.inc
AJAX callback for features_export_form_build().
features_export_build_form_submit in ./features.admin.inc
Form submission handler for features_export_form().
features_export_form in ./features.admin.inc
Form constructor for features export form.
features_export_render in ./features.export.inc
Render feature export into an array representing its files.

... See full list

1 string reference to 'features_get_components'
features_update_6101 in ./features.install
Update 6101: Set codestate signature for all features.

File

./features.module, line 473
Module file for the features module, which enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together statisfy a certain use-case.

Code

function features_get_components($component = NULL, $key = NULL, $reset = FALSE) {
  features_include();
  $components =& drupal_static(__FUNCTION__);
  $component_by_key =& drupal_static(__FUNCTION__ . '_by_key');
  if ($reset || !isset($components) || !isset($component_by_key)) {
    $components = $component_by_key = array();
    if (!$reset && ($cache = cache_get('features_api'))) {
      $components = $cache->data;
    }
    else {
      $components = module_invoke_all('features_api');
      drupal_alter('features_api', $components);
      cache_set('features_api', $components);
    }
    foreach ($components as $component_type => $component_information) {
      foreach ($component_information as $component_key => $component_value) {
        $component_by_key[$component_key][$component_type] = $component_value;
      }
    }
  }
  if ($key && $component) {
    return !empty($components[$component][$key]) ? $components[$component][$key] : NULL;
  }
  elseif ($key) {
    return !empty($component_by_key[$key]) ? $component_by_key[$key] : array();
  }
  elseif ($component) {
    return $components[$component];
  }
  return $components;
}