You are here

function hook_features_api in Features 7

Same name and namespace in other branches
  1. 6 features.api.php \hook_features_api()
  2. 7.2 features.api.php \hook_features_api()

Main info hook that features uses to determine what components are provided by the implementing module.

Return value

array An array of components, keyed by the component name. Each component can define several keys:

'file': Optional path to a file to include which contains the rest of the features API hooks for this module.

'default_hook': The defaults hook for your component that is called when the cache of default components is generated. Examples include hook_views_default_views() or hook_context_default_contexts().

'default_file': The file-writing behavior to use when exporting this component. May be one of 3 constant values:

FEATURES_DEFAULTS_INCLUDED_COMMON: write hooks/components to `.features.inc` with other components. This is the default behavior if this key is not defined.

FEATURES_DEFAULTS_INCLUDED: write hooks/components to a component- specific include named automatically by features.

FEATURES_DEFAULTS_CUSTOM: write hooks/components to a component- specific include with a custom name provided. If your module provides large amounts of code that should not be parsed often (only on specific cache clears/rebuilds, for example) you should use the 2nd or 3rd options to split your component into its own include.

'default_filename': The filename to use when 'default_file' is set to FEATURES_DEFAULTS_CUSTOM.

'feature_source': Boolean value for whether this component should be offered as an option on the initial feature creation form.

'base': Optional. An alternative base key to use when calling features hooks for this component. Can be used for features component types that are declared "dynamically" or are part of a family of components.

'alter_type': What type of alter hook this hook uses. 'normal' is called after the main hook is called. 'inline' is embeded within the default hook and may not be implemented by some default hooks. 'none' is no alter hook exists. Defaults to 'normal'

'alter_hook': What the name of the alter hook for this component is. Do not include the '_alter' part. Defaults to 'default_hook'.

12 functions implement hook_features_api()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_features_api in includes/features.block.inc
Implements hook_features_api().
ctools_component_features_api in includes/features.ctools.inc
Master implementation of hook_features_api() for all ctools components.
ctools_features_api in includes/features.ctools.inc
Implements hook_features_api().
features_features_api in includes/features.features.inc
Implements hook_features_api().
field_features_api in includes/features.field.inc
Implements hook_features_api().

... See full list

1 invocation of hook_features_api()
features_get_components in ./features.module
Returns the array of supported components.

File

./features.api.php, line 52

Code

function hook_features_api() {
  return array(
    'mycomponent' => array(
      'default_hook' => 'mycomponent_defaults',
      'default_file' => FEATURES_DEFAULTS_INCLUDED,
      'feature_source' => TRUE,
      'file' => drupal_get_path('module', 'mycomponent') . '/mycomponent.features.inc',
    ),
  );
}