You are here

function pm_field_base_create_if_required in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 includes/pm.field.inc \pm_field_base_create_if_required()
  2. 7.2 includes/pm.field.inc \pm_field_base_create_if_required()

Create specific field base if not present.

1 call to pm_field_base_create_if_required()
pm_field_bases_create_if_required in includes/pm.field.inc
Iterate through an array of field bases, creating if not present.

File

includes/pm.field.inc, line 38
Field creation functions.

Code

function pm_field_base_create_if_required($field_name, $field_base) {
  try {
    $field = field_info_field($field_name);
    if (empty($field)) {
      $field = field_create_field($field_base);
      return PM_FIELD_BASE_CREATE_SUCCESS;
    }
    else {
      field_update_field($field_base);
      return PM_FIELD_BASE_UPDATE_SUCCESS;
    }
  } catch (Exception $e) {
    watchdog('pm', 'See ' . __FUNCTION__ . '() ' . $e
      ->getTraceAsString(), NULL, WATCHDOG_ERROR);
  }
  return PM_FIELD_BASE_CREATE_FAILURE;
}