You are here

function commerce_kickstart_rebuild_feature in Commerce Kickstart 7.2

Rebuilds a feature using the same logic as features_modules_enabled().

Called from the hook_enable() of every Kickstart feature.

features_modules_enabled() runs too late, so when a feature's hook_enable() or hook_install() runs, the feature hasn't been rebuild yet, no exported structures exist in the system and can't be modified. It also rebuilds all features at once, which makes it prone to timeouts. This is why Kickstart disables features_modules_enabled() and rebuilds each feature manually in its hook_enable() hook.

8 calls to commerce_kickstart_rebuild_feature()
commerce_kickstart_block_enable in modules/commerce_kickstart/commerce_kickstart_block/commerce_kickstart_block.install
Implements hook_enable().
commerce_kickstart_blog_enable in modules/commerce_kickstart/commerce_kickstart_blog/commerce_kickstart_blog.install
Implements hook_enable().
commerce_kickstart_lite_product_enable in modules/commerce_kickstart/commerce_kickstart_lite_product/commerce_kickstart_lite_product.install
Implements hook_enable().
commerce_kickstart_merchandising_enable in modules/commerce_kickstart/commerce_kickstart_merchandising/commerce_kickstart_merchandising.install
Implements hook_enable().
commerce_kickstart_product_enable in modules/commerce_kickstart/commerce_kickstart_product/commerce_kickstart_product.install
Implements hook_enable().

... See full list

File

./commerce_kickstart.profile, line 192

Code

function commerce_kickstart_rebuild_feature($module) {
  $feature = features_load_feature($module, TRUE);
  $items[$module] = array_keys($feature->info['features']);

  // Need to include any new files.
  features_include_defaults(NULL, TRUE);
  _features_restore('enable', $items);

  // Rebuild the list of features includes.
  features_include(TRUE);

  // Reorders components to match hook order and removes non-existant.
  $all_components = array_keys(features_get_components());
  foreach ($items as $module => $components) {
    $items[$module] = array_intersect($all_components, $components);
  }
  _features_restore('rebuild', $items);
}