You are here

civicrm_entity.install in CiviCRM Entity 7.2

Same filename and directory in other branches
  1. 7 civicrm_entity.install

Installation/Un-installation hooks for CiviCRM Entity.

File

civicrm_entity.install
View source
<?php

/**
 * @file
 *  Installation/Un-installation hooks for CiviCRM Entity.
 */

/**
 *  Implements hook_uninstall()
 *
 */
function civicrm_entity_uninstall() {
  drupal_load('module', 'civicrm_entity');
  $civicrm_entity_info = civicrm_entity_get_supported_entity_info();
  foreach ($civicrm_entity_info as $entity_type => $info) {
    field_attach_delete_bundle($entity_type, $entity_type);
  }
  variable_del('civicrm_entity_admin_enabled_entities');
}

/**
 * Implements hook_enable().
 *
 * Set weight higher than CiviCRM.
 *
 * @TODO Actually check what CiviCRM's weight should be.
 */
function civicrm_entity_enable() {
  db_query("UPDATE {system} SET weight = 110 WHERE name = 'civicrm_entity'");
}

/**
 * Blank hook_update_N() to help Drupal notice relocated files in 7.x-2.x.
 */
function civicrm_entity_update_7200() {

  // This space intentionally left blank.
}

/**
 * Flush all caches to help Drupal notice relocated files, additional entities, and updated metadata.
 */
function civicrm_entity_update_7201() {
  drupal_flush_all_caches();
}

/**
 * Create enabled entities variable
 */
function civicrm_entity_update_7202() {
  drupal_load('module', 'civicrm_entity');
  $available_entities = _civicrm_entity_available_entities();
  $settings = [];
  foreach ($available_entities as $drupal_entity_type => $civicrm_api_entity) {
    $settings[$drupal_entity_type] = $drupal_entity_type;
  }
  variable_set('civicrm_entity_admin_enabled_entities', $settings);
}

Functions

Namesort descending Description
civicrm_entity_enable Implements hook_enable().
civicrm_entity_uninstall Implements hook_uninstall()
civicrm_entity_update_7200 Blank hook_update_N() to help Drupal notice relocated files in 7.x-2.x.
civicrm_entity_update_7201 Flush all caches to help Drupal notice relocated files, additional entities, and updated metadata.
civicrm_entity_update_7202 Create enabled entities variable