You are here

function hook_features_api in Features 6

Same name and namespace in other branches
  1. 7.2 features.api.php \hook_features_api()
  2. 7 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.

'features_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.

15 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
Implementation of hook_features_api().
content_features_api in includes/features.content.inc
Implementation of hook_features_api().
context_features_api in includes/features.context.inc
Implementation of 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
Implementation of hook_features_api().

... See full list

4 invocations of hook_features_api()
features_get_components in ./features.module
Returns the array of supported components.
features_get_default_hooks in ./features.export.inc
Gets the available default hooks keyed by components.
features_hook in ./features.module
Checks whether a component implements the given hook.
features_include in ./features.module
Load includes for any modules that implement the features API and load includes for those provided by features.

File

./features.api.php, line 44

Code

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