You are here

function fraction_entity_test_enable in Fraction 7

Implements hook_enable().

File

tests/fraction_entity_test/fraction_entity_test.install, line 77

Code

function fraction_entity_test_enable() {

  // Create the default bundle that is defined in fraction_entity_test_entity_info().
  $bundle_info = array(
    'name' => 'fraction_entity_test_bundle',
    'label' => st('Fraction Entity Test Bundle'),
    'status' => 0x1,
    'module' => 'fraction_entity_test',
  );
  $bundle = new FractionEntityTestType($bundle_info);
  $bundle
    ->save();

  // Add fraction field to make it possible to work with decimals w/o rounding errors.
  $instances_default = _fraction_entity_test_default_instances();
  foreach (_fraction_entity_test_default_fields() as $field_name => $field_default) {
    $field = field_info_field($field_name);
    if (empty($field)) {
      field_create_field($field_default);
    }
    if (!empty($instances_default[$field_name])) {
      $instance = field_info_instance('fraction_entity_test', $field_name, 'fraction_entity_test_bundle');
      if (empty($instance)) {
        field_create_instance($instances_default[$field_name]);
      }
    }
  }
}