You are here

function _commerce_gc_product_example_ensure_config in Commerce GC 7

Ensure that certain configuration elements actually exist.

1 call to _commerce_gc_product_example_ensure_config()
commerce_gc_product_example_modules_enabled in modules/commerce_gc_product_example/commerce_gc_product_example.module

File

modules/commerce_gc_product_example/commerce_gc_product_example.module, line 60

Code

function _commerce_gc_product_example_ensure_config() {
  $module = 'commerce_gc_product_example';

  // Copied from features_modules_enabled():
  $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);

  // This is necessary to ensure that giftcard products have a price when we are
  // setting it.
  commerce_product_configure_product_type('giftcard');
}