function features_get_components in Features 7.2
Same name and namespace in other branches
- 6 features.module \features_get_components()
- 7 features.module \features_get_components()
Gets component types declared with hook_features_api().
Parameters
string $component: (optional) A specific type of component that supports features. E.g. "field_instance".
string $key: (optional) The name of a property to retrieve for each component type. E.g. "name", "default_hook" or "base".
bool $reset: (optional) If TRUE, the components cache will be cleared.
Return value
mixed|mixed[]|array|array[]|null Return value depending on parameters:
- If both $component and $key are provided: A specific value from the info of the specified component.
- If only $key is provided: List with the same value from each component.
- If only $component is provided: Info array of the specified component. If the component is not found, a notice is triggered, and NULL is returned.
- If neither $component nor $key are provided: List of component info arrays, keyed by component.
See also
20 calls to features_get_components()
- FeaturesEnableTestCase::testFeaturesGetComponents in tests/
features.test - Run test for features_get_components on enable.
- features_export_build_form_submit in ./
features.admin.inc - First submit handler 'Generate feature' and 'Download feature' buttons.
- features_export_render in ./
features.export.inc - Render feature export into an array representing its files.
- features_get_component_states in ./
features.export.inc - Retrieve an array of features/components and their current states.
- features_get_conflicts in ./
features.module - Detects potential conflicts between features that provide the same items.
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 649 - Main *.module file for the 'features' module.
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', 'cache_features'))) {
$components = $cache->data;
}
else {
$components = module_invoke_all('features_api');
drupal_alter('features_api', $components);
cache_set('features_api', $components, 'cache_features');
}
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;
}