You are here

function commerce_file_configure_line_item_fields in Commerce File 7

Configures line item types defined by other modules that are enabled after the Commerce File module.

Parameters

$modules: An array of module names whose line item type fields should be configured; if left NULL, will default to all modules that implement hook_commerce_line_item_type_info().

3 calls to commerce_file_configure_line_item_fields()
commerce_file_enable in ./commerce_file.module
Implements hook_enable().
commerce_file_modules_enabled in ./commerce_file.module
Implements hook_modules_enabled().
commerce_file_update_7103 in ./commerce_file.install
Ensure all line item types have been configured

File

./commerce_file.module, line 1086
Provides integration of file licenses with Commerce

Code

function commerce_file_configure_line_item_fields($modules = NULL) {

  // If no modules array is passed, recheck the fields for all line item types
  // defined by enabled modules.
  if (empty($modules)) {
    $modules = module_implements('commerce_line_item_type_info');
  }

  // Reset the line item cache to get the default options and callbacks.
  commerce_line_item_types_reset();

  // Loop through all the enabled modules.
  foreach ($modules as $module) {

    // If the module implements hook_commerce_line_item_type_info()...
    if (module_hook($module, 'commerce_line_item_type_info')) {

      // Loop through and configure the line item types defined by the module.
      foreach (module_invoke($module, 'commerce_line_item_type_info') as $type => $line_item_type) {

        // Load the line item type to ensure we have callbacks set.
        $line_item_type = commerce_line_item_type_load($type);
        commerce_file_configure_line_item_type($line_item_type);
      }
    }
  }
}