function crm_core_relationship_field_attach_create_bundle in CRM Core 7
Same name and namespace in other branches
- 8.3 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_field_attach_create_bundle()
- 8 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_field_attach_create_bundle()
- 8.2 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_field_attach_create_bundle()
Implements hook_field_attach_create_bundle.
1 call to crm_core_relationship_field_attach_create_bundle()
- crm_core_relationship_update_7000 in modules/
crm_core_relationship/ crm_core_relationship.install - Adding "status" field to crm_core relationships.
File
- modules/
crm_core_relationship/ crm_core_relationship.module, line 274 - CRM Core Relationship, handles relationship logic and API.
Code
function crm_core_relationship_field_attach_create_bundle($relation_type, $relation_bundle) {
if (crm_core_relationship_is_relationship_type($relation_bundle)) {
module_load_include('inc', 'crm_core_relationship', 'crm_core_relationship.fields');
$fields = _crm_core_relationship_field_default_fields();
// Create the fields if they don't exist
foreach ($fields as $field) {
$info = field_info_field($field['field_name']);
if (empty($info)) {
field_create_field($field);
}
}
$field_instances = _crm_core_relationship_field_status_instance($relation_bundle);
// Create field instances if they don't exist
foreach ($field_instances as $instance) {
$info_instance = field_info_instance('relation', $instance['field_name'], $relation_bundle);
if (empty($info_instance)) {
field_create_instance($instance);
}
}
}
}