You are here

function features_include_defaults in Features 6

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

Load features includes for all components that require includes before collecting defaults.

4 calls to features_include_defaults()
content_features_export in includes/features.content.inc
Implementation of hook_features_export().
features_get_default in ./features.export.inc
Get defaults for a given module/component pair.
features_get_default_map in ./features.export.inc
Get a map of components to their providing modules.
fieldgroup_features_export in includes/features.fieldgroup.inc
Implementation of hook_features_export().

File

./features.module, line 298
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_include_defaults($components = NULL, $reset = FALSE) {
  static $included = array();
  static $include_components;

  // Build an array of components that require inclusion:
  // Views, CTools components and those using FEATURES_DEFAULTS_INCLUDED.
  if (!isset($include_components) || $reset) {
    $include_components = features_get_components();
    foreach ($include_components as $component => $info) {
      if ($component !== 'views' && !isset($info['api']) && (!isset($info['default_file']) || $info['default_file'] !== FEATURES_DEFAULTS_INCLUDED)) {
        unset($include_components[$component]);
      }
    }
  }

  // If components are specified, only include for the specified components.
  if (isset($components)) {
    $components = is_array($components) ? $components : array(
      $components,
    );
  }
  else {
    $components = $include_components;
  }
  foreach ($components as $component) {
    if (isset($include_components[$component]) && (!isset($included[$component]) || $reset)) {
      $info = $include_components[$component];

      // Inclusion of defaults for Views.
      if ($component === 'views') {
        views_include('view');
        views_include_default_views();
      }
      else {
        if (isset($info['api'], $info['module'], $info['current_version'])) {
          ctools_include('plugins');
          ctools_plugin_api_include($info['module'], $info['api'], $info['current_version'], $info['current_version']);
        }
        else {
          $features = isset($features) ? $features : features_get_features(NULL, $reset);
          foreach ($features as $feature) {
            module_load_include('inc', $feature->name, "{$feature->name}.features.{$component}");
          }
        }
      }
      $included[$component] = TRUE;
    }
  }
}