You are here

function entity_background_create_bd_field_group in Entity background 7

Helper function used to create a field group on the bd field collection.

Parameters

string $group_name: A name of the group to be created.

string $label: A label of the group to be created.

array $fields: An array of fields that should be assigned to the group.

int $weight: A weight of the newly created group among the other fields.

Return value

\stdClass

3 calls to entity_background_create_bd_field_group()
entity_background_color_install in module/entity_background_color/entity_background_color.install
Implements hook_install().
entity_background_image_install in module/entity_background_image/entity_background_image.install
Implements hook_install().
entity_background_parallax_install in module/entity_background_parallax/entity_background_parallax.install
Implements hook_install().

File

./entity_background.module, line 294
Module file entity background.

Code

function entity_background_create_bd_field_group($group_name, $label, $fields, $weight = 0) {

  // Set variables.
  $entity_type = EB_FC_ENTITY;
  $bundle = EB_FIELD;
  $mode = 'form';

  // Find existing group.
  $groups = field_group_read_groups();
  if (empty($groups[$entity_type][$bundle][$mode][$group_name])) {

    // Get field group object.
    $field_group = entity_background_add_field_group($group_name, $entity_type, $bundle);

    // Get data array.
    $data = entity_background_get_field_group_data($label, $fields, $weight);

    // Merge data array into field group object.
    $field_group += $data;

    // Convert array into an object.
    $field_group = (object) $field_group;

    // Create field group.
    field_group_group_save($field_group);

    // Enable export.
    ctools_include('export');
    ctools_export_crud_enable('field_group', $field_group->identifier);

    // Return new group.
    return $field_group;
  }

  // Get loaded entity.
  $field_group = $groups[$entity_type][$bundle][$mode][$group_name];
  return $field_group;
}