You are here

function crm_core_relationship_install in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_relationship/crm_core_relationship.install \crm_core_relationship_install()
  2. 8.2 modules/crm_core_relationship/crm_core_relationship.install \crm_core_relationship_install()
  3. 7 modules/crm_core_relationship/crm_core_relationship.install \crm_core_relationship_install()

Implements hook_install().

File

modules/crm_core_relationship/crm_core_relationship.install, line 14
Install, update and uninstall functions for the relationship module.

Code

function crm_core_relationship_install() {

  // Add default relationships.
  $relation_types_info = [
    [
      'relation_type' => 'crm_friend',
      'label' => t('Friend of'),
      'source_bundles' => [
        'crm_core_contact:individual',
      ],
      'r_unique' => TRUE,
    ],
    [
      'relation_type' => 'crm_employee',
      'label' => t('Employee of'),
      'reverse_label' => t('Employer of'),
      'directional' => TRUE,
      'r_unique' => TRUE,
      'source_bundles' => [
        'crm_core_contact:individual',
      ],
      'target_bundles' => [
        'crm_core_contact:organization',
      ],
    ],
    [
      'relation_type' => 'crm_member',
      'label' => t('Member of'),
      'reverse_label' => t('Household for'),
      'directional' => TRUE,
      'r_unique' => TRUE,
      'source_bundles' => [
        'crm_core_contact:individual',
      ],
      'target_bundles' => [
        'crm_core_contact:household',
      ],
    ],
  ];
  foreach ($relation_types_info as $relation_type_info) {
    RelationType::create($relation_type_info)
      ->save();
  }
}